1 #!/usr/bin/expect
2 set timeout 1
3 if { $argc != 1 } {
4 send_user "Usage:cmd telnetip \n"
5 exit
6 }
7
8 send_user "remote telnet ip is $argv \n"
9
10 spawn telnet $argv
11 expect {
12 "login:" { send "root\r"}
13 timeout { send_user "$argv is not alive\n"
14 exit 1
15 }
16 }
17 expect {
18 "*word*" {send "\r"}
19 "*#" {send "\r"}
20 }
21 #send "cd /bin;ftpget -u usrname -p password ip sfile dfile\r""
23 expect "#"
24 send "date ; ls -l dfile\r"
25 expect "#"
26 send "exit\r"
27 expect eof
阅读(1498) | 评论(0) | 转发(0) |