我有一个自动化脚本,该脚本会安装一个新映像“ flash.sh”,我试图从地理位置不同的位置运行该Flash脚本,当我使用“ expect”命令调用该脚本脚本时,它意外地挂在了另一个位置脚本在不同的运行阶段。 电话是..
expect -c 'set timeout 1800;exp_internal 1;match_max 10000;spawn ssh root@client "sh /tmp/flash.sh 'root@server:/loc/test.sdcard'";expect "*?assword:"; send "pass\r"; interact'
script flash.sh,正在使用pivot_root创建mount,移动坐骑,最后使用
dd if=./$IMAGE_FILENAME of=/dev/mmc.. bs=1M
我尝试添加调试并向远程脚本添加睡眠,但是仍然是相同的行为。按cntrl + c
后 Killed by signal 2.
interact: received eof from spawn_id exp6
tty_set: raw = 0, echo = 1
argv[0] = expect argv[1] = -c argv[2] = set timeout 1800;exp_internal 1;match_max 10000;spawn ssh root@xx.xx.xx.xx "sh /tmp/sw_flash.sh root:/loc/test.sdcard";expect "*?assword:"; send "pass\r"; interact
set argc 0
set argv0 "expect"
set argv ""
tty_set: raw = 5, echo = 0
我也使用了调试模式,但是没有错误或没有超时。 PS:当我在同一地理位置的计算机上运行相同的脚本时,所有命令均按预期方式通过。
请帮助..几天来一直在苦苦挣扎
编辑1: 按照建议的方式添加详细信息,并更改交互以期望达到EOF,我不得不使用Cntrl + C
杀死 expect: does " \r\nunmounting /mnt/net and recreating this directory\r\numount: /mnt/net: mountpoint not found\r\nprovided path is not mounted\r\ncreating /mnt/net was successful\r\nstopping services\r\nCan't find /test/service/main.pyc! Using /test/service/main.py instead.\r\nStopping Service: /usr/bin/python3 /test/service/main.py\r\nSUCCESSFULLY STOPPED\r\nmounting remote rootfs from test@server:/test/images/latest at /mnt/net\r\nsshfs mount command was successful\r\nwaiting for 120 seconds for the system to be ready for rootfs change in case it is not\r\nchanging rootfs to ./mnt/net/oldroot\r\nwaiting for 120 seconds for the system to be ready for rootfs change in case it is not\r\n" (spawn_id exp6) match glob pattern "EOF"? no
^Csighandler: handling signal(2)
async event handler: Tcl_Eval(exit 130)