请问我想用ssh 传一档案从 A server 到 B server执行
所有指令写在档案fileA 执行ok 但是我用fileB 去执行file A
他却会在前一行个expect还没执行完就执行下一行我试了interact and expect eof都不行
我应该如何写 谢谢
file A
#!/bin/bash
echo "start"
expect -c 'set timeout 5; spawn -noecho ssh -o StrictHostKeyChecking=no 'user'@'ip' mkdir 'dir'; expect *password:*; send "'passwd'\r"; interact'
expect -c 'set timeout 5; spawn -noecho scp -o StrictHostKeyChecking=no 'file' 'user'@'ip':'RemoteTMPDir'/; expect *password:*; send "'passwd'\r"; interact'
expect -c 'set timeout 5; spawn -noecho ssh -o StrictHostKeyChecking=no 'user'@'ip' bash -s < 'file'; expect *password:*; send "'passwd'\r"; interact'
expect -c 'set timeout 5; spawn -noecho ssh -o StrictHostKeyChecking=no 'user'@'ip' rm -f 'file'; expect *password:*; send "'passwd'\r"; expect eof'
echo "done"
file B
#!/bin/bash
echo "./A.sh"