linux下的ssh、telnet登录脚本(tcl)
2007-08-08 17:03
操作系统:linux(feroda4)
tcl版本:tclsh8.4
expect:5.43.0
ssh登录脚本
#!/usr/bin/tclsh8.4
package require Expect
set user "root"
set host "10.2.26.30"
spawn ssh $user@$host
expect {
-re "password: $" {exp_send "密码\r"; exp_continue}
}
telnet登录脚本
#!/usr/bin/tclsh8.4
package require Expect
set user "test"
set host "10.2.26.30"
set port "23"
spawn telnet $host $port
expect {
-re "login: $" {exp_send "$user\r"; exp_continue}
-re "Password: $" {exp_send "test密码\r"}
}
PS:10.2.26.30为linux主机,若登录其他设备,更改匹配字符即可
转载于:https://blog.51cto.com/huqilong/198400