[liuyx@higinet ~]$ cat liu.sh
#!/usr/bin/expect -f
set user [lindex $argv 0]
set pass [lindex $argv 1]
set ip [lindex $argv 2]
if {$argc<3} {
puts stderr "Usage: $argv0 user password ip.\n "
exit 1
}
set timeout 30
spawn scp -r aa.txt
while {1} {
expect {
"Are you sure you want to continue connecting (yes/no)?" {
send "yes\r"
}
"password:" {
send "$pass\r"
}
"Permission denied*" {
break
}
"*No route to host" {
break
}
"*No such file or directory" {
break
}
timeout {
break
}
eof {
break
}
}
}
#expect eof
#interact
exit 0
阅读(1281) | 评论(0) | 转发(0) |