Loading

expect使用示例

#!/bin/bash
PASS='password'
for ip in $(cat ip.txt); do
   expect -c "
       set timeout 5;
       spawn scp -rp ip.txt root@$ip:/tmp
       expect {
          \"(yes/no)\" {send \"yes\r\"; exp_continue}
          \"password:\" {send \"$PASS\r\"; exp_continue}
       }
    "
   echo ""
done
posted @ 2023-02-21 17:01  小维江湖  阅读(18)  评论(0)    收藏  举报