Jump to content

Scripting DOS commands and DOS program input


jly
 Share

Recommended Posts

Hi all,

I just found out and tried to use AutoIt to script some intensive computational analysis programs I'm using. Basically, I'm trying to use the command console to run a program and then input commands into that program, and then trying to loop them together. I tried to use just SEND commands, but what I've found happens is that in random places within the script, the commands and the console get desynchronized, and I don't get the output I want, as gibberish goes into the console until it resets back to the proper state.

So for example, here's a chunk of my script:

Send("dnapars{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.pars{ENTER}")
Send("o{ENTER}")
Send("44{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.parstree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

Send("dnaml{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.ml{ENTER}")
Send("o{ENTER}")
Send("44{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.mltree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

Send("dnadist{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.dist{ENTER}")
SEND("y{ENTER}")
SEND("{ENTER}")

Send("neighbor{ENTER}")
SEND("test25-054.dist{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.nb{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.nbtree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

dnapars, dnaml, dnadist, and neighbor are all .exes, the first filename entered in each block is an input file, the others are output files, and the other commands are just navigating the program's menus and options. (Some of you may recognize these as bioinformatics applications.)

Anyways, like I said, this code will work fine, but when I try to script together hundreds, it breaks down. I'm positive my script is consistent, since I generated it using Java loops, so are there other AutoIt commands I should be using, maybe to separate the .exe calls and the program inputs, or to check the output from each command before entering the next one (and program block if there's an error within)?

It's okay if the script misses some of the blocks, so long as output files aren't improperly generated, so I can go back and check which outputs need to be regenerated. What's not okay is if the script gets out of sync and responds with improper filenames and commands, since my output will be misleading.

Any help would be appreciated, thanks!

Link to comment
Share on other sites

Hi all,

I just found out and tried to use AutoIt to script some intensive computational analysis programs I'm using. Basically, I'm trying to use the command console to run a program and then input commands into that program, and then trying to loop them together. I tried to use just SEND commands, but what I've found happens is that in random places within the script, the commands and the console get desynchronized, and I don't get the output I want, as gibberish goes into the console until it resets back to the proper state.

So for example, here's a chunk of my script:

Send("dnapars{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.pars{ENTER}")
Send("o{ENTER}")
Send("44{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.parstree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

Send("dnaml{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.ml{ENTER}")
Send("o{ENTER}")
Send("44{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.mltree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

Send("dnadist{ENTER}")
SEND("test25-054.phy{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.dist{ENTER}")
SEND("y{ENTER}")
SEND("{ENTER}")

Send("neighbor{ENTER}")
SEND("test25-054.dist{ENTER}")
SEND("f{ENTER}")
SEND("test25-054.nb{ENTER}")
SEND("y{ENTER}")
SEND("f{ENTER}")
SEND("test25.nbtree{ENTER}")
SEND("A{ENTER}")
SEND("{ENTER}")

dnapars, dnaml, dnadist, and neighbor are all .exes, the first filename entered in each block is an input file, the others are output files, and the other commands are just navigating the program's menus and options. (Some of you may recognize these as bioinformatics applications.)

Anyways, like I said, this code will work fine, but when I try to script together hundreds, it breaks down. I'm positive my script is consistent, since I generated it using Java loops, so are there other AutoIt commands I should be using, maybe to separate the .exe calls and the program inputs, or to check the output from each command before entering the next one (and program block if there's an error within)?

It's okay if the script misses some of the blocks, so long as output files aren't improperly generated, so I can go back and check which outputs need to be regenerated. What's not okay is if the script gets out of sync and responds with improper filenames and commands, since my output will be misleading.

Any help would be appreciated, thanks!

I expect the problem is that you are firing lots of information using send without knowing that the application is in a stage where it can receive it or respond to it. At the very least maybe you could try adding some sleep statements in between each line to give the application you're talking to a chance to catch its breadth. But without anything to check the state of the application such as waiting for some change or response, it is always going to be unreliable.

If you are able to check something to tell you the effect of your Send then you would improve things a lot.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I expect the problem is that you are firing lots of information using send without knowing that the application is in a stage where it can receive it or respond to it. At the very least maybe you could try adding some sleep statements in between each line to give the application you're talking to a chance to catch its breadth. But without anything to check the state of the application such as waiting for some change or response, it is always going to be unreliable.

If you are able to check something to tell you the effect of your Send then you would improve things a lot.

I can't realistically use sleep statements since I can't be sure of how long each run takes, since it's data-dependent.

Are there AutoIt commands I could use to check output? (The only outputs will be to the command console and newly created output files.)

Link to comment
Share on other sites

I can't realistically use sleep statements since I can't be sure of how long each run takes, since it's data-dependent.

Are there AutoIt commands I could use to check output? (The only outputs will be to the command console and newly created output files.)

great improvements in handling stdout have been made3, look for runreadstd.au3 posts.....

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

great improvements in handling stdout have been made3, look for runreadstd.au3 posts.....

runreadstd.au3 only seems to be found in this thread! Can you give a link flyingboz?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...