Jump to content

Telnet and expect like function


Recommended Posts

I am wondering if someone could tell me if AutoIt has any Q&A+timeout+fallback mechanism that is similar to Expect. In a brief summary for those who aren't familiar with Expect, Expect is a command line automation tool that is focused on Q&A+timeout sets. You would Send() a command and Expect() some string on the screen with X seconds. Depending on if the result is Found() or not, different commands would be executed. The user can Expect() multiple options as well, so that the target program can be dynamically(yet finitely determined) managed.
I would like to telnet to my linux machine.  Check check the memory and write to a log the results of the test.  

I'm using putty because i didn't have a good telnet program in windows.


Run("c:/putty.exe -load dan")
AutoItSetOption("SendKeyDelay", 200)
Send("user{ENTER}")
Sleep(500)
Send("password{ENTER}")
Sleep(500)
Send("memtest{ENTER}")
Send("echo $?")
** If output is 0 **
Send("echo PASS > log.txt")
** If output is 1 **
Send("echo FAIL > log.txt")
** If output is hung (timeout) **
Send("echo HUNG > log.txt")

I'll be running more system checks along with this, but this would be a good basis to start on.

Also does autoit have telnet type of routines already? 

Thanks,
Dan

Edited by bigdogdan2
Link to comment
Share on other sites

  • Moderators

As far as "telnet routines", have you searched the forum yet? A simple search returned c. 600 results for me.

As far as your Expect() function, AutoIt doesn't have any pre-defined "wait x number of seconds and if no response do this" function. It does, however, support a wide array of error checking to confirm you get the results you're after.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...