How to automate telnet session using Expect?

后端 未结 4 1167
一个人的身影
一个人的身影 2020-12-19 06:56

I\'m trying to write an expect script to automate telnet. This is what I have so far.

#!/usr/bin/expect
# Test expect script to telnet.

spawn telnet 10.62.         


        
4条回答
  •  悲哀的现实
    2020-12-19 07:24

    You're sending the echo command without first expecting the prompt. Try:

    # after sending the password
    expect -re "> ?$"
    send "echo HELLO WORLD\r"
    expect eof
    

提交回复
热议问题