Can anyone tell me how I can simply using expect, telnet to a host, get the login prompt, end the telnet session right there and then send the results to variable.
PHP Code:
telnet 192.168.1.2
Trying 192.168.1.2...
Connected to 192.168.1.2.
Escape character is '^]'.
login:
telnet> quit
Connection to 192.168.1.2 closed.
but instead:
PHP Code:
#
# in the script. # Open a telnet session to a remote server, and wait for a prompt.
spawn telnet $remote_server
expect "login:"
# Exit the telnet session.
send "exit\r"
# Capture the results of the command into a variable. This can be displayed, or written to disk.
set results $expect_out(buffer)
Thanks