#!/usr/bin/expect
# Assume $remote_server, $my_user_id, $my_password, and $my_command were read in earlier
# in the script.
# Open a telnet session to a remote server, and wait for a username prompt.
set remote_server 16.157.64.42
set port 30600
set login "auth s usera"
set lout lout
spawn telnet $remote_server $port
#expect "username:"
expect "^* OK IMAP"
# Send the username, and then wait for a password prompt.
send "$login\r"
expect "OK"
# Send the password, and then wait for a shell prompt.
send "$lout\r"
expect "OK"
# Send the prebuilt command, and then wait for another shell prompt.
#send "$my_command\r"
#expect "%"
# Capture the results of the command into a variable. This can be displayed, or written to disk.
#set results $expect_out(buffer)
# Exit the telnet session, and wait for a special end-of-file character.
#send "exit\r"
#expect eof
阅读(3488) | 评论(0) | 转发(0) |