Sign in to follow this  
Followers 0
Guest Mark1Up

Automating Terminal Session - Need help

4 posts in this topic

Hi,

I'm new to AutoIt but have some decent BASIC programming background. I'd like to use AutoIt to control a terminal session (Putty using SSH) to a Cisco router and grab some info from the router and display it in an AutoIt GUI.

I can start the Putty session with the Run command like this:

Run("putty.exe -ssh -pw password username@192.168.1.1")

But I would like to have the user input the username, password & IP into the AutoIT gui and then bring up the Putty session based on the runtime input. I tried this but the Run command doesn't seem to like a string variable.

$puttyname="username"

$puttypw="password"

$ip="192.168.1.1"

$StartPutty="putty.exe -ssh -pw "+$puttypw+" "+$puttyname+"@"+$ip

Run($Startputty)

Should this work (maybe just a syntax issue)? Any ideas on how I could get this working (or work-around it)?

My second question is how to get the text output of the terminal session fed back to AutoIt so I can parse and display the selected info. I can use the Send command to send the router commands to the Putty terminal session, but I don't see how I can get the resulting text output back into AutoIt for processing and display.

Any ideas or suggestions would be appreciated (even it the answer is that AutoIt isn't the right tool for this kind of application would be helpful).

Thanks,

Mark

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$StartPutty="putty.exe -ssh -pw "+$puttypw+" "+$puttyname+"@"+$ip

$StartPutty="putty.exe -ssh -pw "&$puttypw&" "&$puttyname&"@"&$ip

AutoIt concatenation is with &

(untested - might not have & and "" in right places)

Search forum for Putty - this has all been done before. :-)

edit:typos

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Plato,

Thanks for the tip on using the "&" to concatenate the strings that seems to do the trick for the Run command with a string variable.

I already did a forum search on "Putty" and didn't really see anything on getting psuedo "interactive" feeback from a Putty session to AutoIt (mostly some discussion on window resizing). The main area in the terminal session doesn't show up a windows control (using the AU3Info tool) so I was not sure how to get info back from the terminal session.

I did find some examples of using StdoutRead so I'll give that a go and see if Putty will play ball.

Mark

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