I want to connect a machine by telnet. Attempting to use Expect is not working. There is no username and password. Here is where I'm at.
#!/usr/bin/expect -f
Echo Hello World
telnet IP_Address_Here 10001
expect "]'."
send "^a200\r"
This works up to the 'expect'. This is the result of the code...
Roberts-MacBook:~ rameeti$ sh test.sh
Hello World
Trying IP_Address_Here...
Connected to IP_Address.lightspeed.irvnca.sbcglobal.net.
Escape character is '^]'.
And then it sits waiting for the command that I want to send: "^a200" Why is the 'expect' not working?
I guess you are executing it with bash
instead of expect
.
Otherwise, you will receive
invalid command name "Echo"
while executing
"Echo Hello World"
try
$ expect -f test.sh
BTW, you should not name it .sh
if it's expect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.