Sign in to follow this  
Followers 0
bigdogdan2

Telnet and expect like function

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

You could use "Console Telnet".

It allows to redirect the STDIN and STDOUT so you can better manage it with autoit via streams instead of send()

>Here I posted an example on how to use it.


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
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
Sign in to follow this  
Followers 0