[問題] 用ssh 傳檔去執行
請問我想用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"
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 71.190.171.54
→
04/12 23:55, , 1F
04/12 23:55, 1F
→
04/13 14:23, , 2F
04/13 14:23, 2F
→
04/13 14:29, , 3F
04/13 14:29, 3F
→
04/13 14:29, , 4F
04/13 14:29, 4F
→
04/21 13:19, , 5F
04/21 13:19, 5F
推
04/24 06:37, , 6F
04/24 06:37, 6F
→
04/24 06:37, , 7F
04/24 06:37, 7F
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章