标签:telnet
#!/usr/bin/expect #if it all goes pear shaped the script will timeout after 20 seconds. set timeout 20 #First argument is assigned to the variable name set name [lindex $argv 0] #Second argument is assigned to the variable user set user [lindex $argv 1] #Third argument is assigned to the variable password set password [lindex $argv 2] #This spawns the telnet program and connects it to the variable name spawn telnet $name #The script expects login expect "Login:" #The script sends the user variable send "$user\n" #The script expects Password expect "Password:" #The script sends the password variable send "$password\n" #This hands control of the keyboard over two you (Nice expect feature!) expect ">" send "sh\n" send "cd /var/p2pcdn\n" send "LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:./Lib\n" send "tar -zxvf com.chinatelecom.fenghuo.smartgateway.p2pcdn.cpk\n" send "cd ./MyPlugin\n" #send "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./Lib\n" send "./p2p_client&\n" interact
标签:telnet
原文地址:http://cmd10.blog.51cto.com/5254418/1825830