expect 發送腳本

scp.sh

#!/usr/bin/expect

set timeout 120
set host [lindex $argv 0]

spawn scp -r /tmp/recommend.id prestat@$host:/tmp/ 
expect {
   "(yes/no)?"
       {
             send "yes\n"
             expect "*assword:" { send "Sta*UHB7ujm\n"}
        }
           "*assword:"
           {
            send "Sta*UHB7ujm\n"
            }
}
expect "100%"
expect eof
exit 0

prestat 是用戶名
Sta*UHB7ujm\n 是mi密碼

          • date >> time.txt && scp.sh 10.211.138.21 #就把time.txt 這個文件發送到了10.211.138.21 這個主機上邊
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章