- 论坛徽章:
- 0
|
ip1.txt文件内容如下
ip password
ip password
ip password
ip password
ip password
怎么把ip 和密码读出来并且访问它
用这段不行
#!/usr/bin/expect -f
set file [open ip1.txt r]
spawn ssh -p 57891 root@×.×.×.×
expect {
"*(yes/no)?" {send "yes\r"}
"*password:" {send "12345678\r"}
}
expect "*~]$"
while{[gets $file line]>=0}
{
send "scp -P 57891 root@[lindex $line 0]:./*\[0-9t\].tracert* /home/root/popresult\r"
expect {
"*(yes/no)?" {send "yes\r"}
"*password:" {send "[lindex $line 1]\r"}
}
expect "*100%"
expect eof
close
}
close $file
expect -d 调试信息如下
expect version 5.42.1
argv[0] = expect argv[1] = -d argv[2] = expect.sh
set argc 0
set argv0 "expect.sh"
set argv ""
executing commands from command file expect.sh
spawn ssh -p 57891 root@×.×.×.×
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {30204}
expect: does "" (spawn_id exp5) match glob pattern "*(yes/no)?"? no
"*password:"? no
root@×.×.×.×'s password:
expect: does "root@×.×.×.×'s password: " (spawn_id exp5) match glob pattern "*(yes/no)?"? no
"*password:"? yes
expect: set expect_out(0,string) "root@×.×.×.×'s password:"
expect: set expect_out(spawn_id) "exp5"
expect: set expect_out(buffer) "root@×.×.×.×'s password:"
send: sending "12345678\r" to { exp5 }
expect: does " " (spawn_id exp5) match glob pattern "*~]$"? no
expect: does " \r\n" (spawn_id exp5) match glob pattern "*~]$"? no
Last login: Tue Nov 11 01:54:06 2008 from 222.141.223.144
expect: does " \r\nLast login: Tue Nov 11 01:54:06 2008 from 222.141.223.144\r\r\n" (spawn_id exp5) match glob pattern "*~]$"? no
[root@sh191 ~]$
expect: does " \r\nLast login: Tue Nov 11 01:54:06 2008 from 222.141.223.144\r\r\n\u001b]0;root@sh191:~\u0007[root@sh191 ~]$ " (spawn_id exp5) match glob pattern "*~]$"? no
expect: timed out
invalid command name "while{28>=0}"
while executing
"while{[gets $file line]>=0}"
(file "expect.sh" line 10)
我这个ip1.txt文件有101行 怎么会是while{28>=0} 不明白 |
|