使用expect實現跨主機免密傳輸

#!/usr/bin/expect

set timeout 1
set filename [lindex $argv 0]
set ip [lindex $argv 1]
spawn scp -l 1000 root:/bigdate/file/${filename} zsj@${ip}:/home/zsj/shell/txt/
 expect {
 "(yes/no)?"
  {
  send "yes\n"
  expect "*assword:" { send "123456\n"}
 } 
 "*assword:"
{
 send "123456\n"
}
}
expect "100%"
expect eof
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章