Sign in to follow this  
Followers 0
Tiger1vic

Using Send and capturing responses

2 posts in this topic

Hello all. I am still a beginner with AutoIt and have written a script to automate the configuration of network cards in our UPS's. I launched telnet and used 'Send' commands to do most of this, and for the most part it works well.

There are two parts to my question. First, the use of 'Send' works well as long as you leave the telnet window open and with focus. If you forget this rule and inadvertently click another window, it keeps 'Send'ing to that other window, regardless of what's in it. So if for example, you click on a Word doc, it starts modifying your doc with the AutoIt keystrokes -- yikes! I'm wondering if there's a way I can protect my system (preferably without pausing the script) from this behaviour. In other words, can it continue sending keystrokes to the telnet program in the background if another window becomes active? I figured I could have it pause the script if another window gets focus, but then I couldn't continue working on something else while the script is running. I would still have to return to the script and wait idly for it to finish.

The other part of my question is actually another question, but it's a companion to this one :P

Before I run this updating process, I have to grab the current configuration off the UPS, because part of my update is a firmware upgrade which sets everything back to defaults. So.... I would like to somehow use AutoIt to 'grab' the current configuration before I do the firmware update. Then part 2 would be to replace that original configuration using my existing script.

There doesn't appear to be any way to grab the ups config other than to telnet to it and go into each of the numbered menu screens to view the settings. This is what I do manually right now, logging the session as I go. Then I copy and paste the required parameters from that logged session into an .INI file which my AutoIt script uses as parameter inputs. Obviously the session log contains a whole lot of crap that is irrelevant, so I manually pick the things I need. I was thinking that if there was such a thing as a 'waitfor' command in AutoIt, I could have it wait for a specific string to come back, then capture the parameter immediately following that string, wait again for the next recognizable string, capture the parameter following.... and so on. So for example, one of these combinations might be -- 'wait for "Battery Installation Date" ' and then capture the next XX characters to a file. Then 'wait for "NTP server" ' and capture/append the next XX characters to the same file, and so on. Of course, the number 'XX' could change, so it would be better if it waited for a certain string, then captured everything UP TO the next specified string. That way I could specify the KNOWN strings that remain constant (ie: the menu prompts, but not my parameters -- the parameters would form 'XX').

Am I explaining this clearly enough? I've searched the documentation and the forums and either there is no such functionality or I'm just not a very good searcher :)

Can anyone help, either with code to do this, or some pointers about where I should be looking? Thanks so much, in advance!

Share this post


Link to post
Share on other sites



Anyone?? Have I not explained this clearly enough, or am I actually trying to do something that no one else here knows how to do either? If it's THAT complicated, maybe it's beyond my capabilities anyway but please, if you have any helpful ideas (or code), let me know. Doing this procedure manually is such a time-waster :)

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