Sign in to follow this  
Followers 0
insp

DAU Question for Dos-Commandline Scripting

6 posts in this topic

I will Script a old DOS-Application with Masks. That someone can extend my Scrip, a simple draft in pure DOS. I can not find a Autoit-Command send abcd and wait until 1234 is received, Timeout-Parameter (if not received de right Characters) after a specific Time

Hiere the begin of my Example

Run("cmd.exe")

WinWaitActive("C:\WINDOWS\system32\cmd.exe")

AutoItSetOption("SendKeyDelay", 15)

sleep (1000)

Send("net use{enter}")

Now in free Text

if the respose "ok g:" Rem Drive G: is Mounted jump to Label_OK

if everything else send "rubbish receive to the Display and exit

if no Character is received send no Character is received send " to Display and exit

Remark: "ok g:" ist not the last output from the Commandline

Label_Ok

next steps

Thanks for your help

Share this post


Link to post
Share on other sites



I will Script a old DOS-Application with Masks. That someone can extend my Scrip, a simple draft in pure DOS. I can not find a Autoit-Command send abcd and wait until 1234 is received, Timeout-Parameter (if not received de right Characters) after a specific Time

Hiere the begin of my Example

Run("cmd.exe")

WinWaitActive("C:\WINDOWS\system32\cmd.exe")

AutoItSetOption("SendKeyDelay", 15)

sleep (1000)

Send("net use{enter}")

Now in free Text

if the respose "ok g:" Rem Drive G: is Mounted jump to Label_OK

if everything else send "rubbish receive to the Display and exit

if no Character is received send no Character is received send " to Display and exit

Remark: "ok g:" ist not the last output from the Commandline

Label_Ok

next steps

Thanks for your help

With StdInWrite() and StdOutRead() you can pipe things in/out of command line execution, but the special console window just isn't very scriptable. You need to put what you want in a batch file and run that from AutoIt, or better, convert the individual command lines to separate AutoIt functions. For example, instead of sending "net use{ENTER}" to the console window, Run("Net.exe USE") from inside the AutoIt script and use one of the various methods for capturing the output (redirect to a file or hook to STDOUT).

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

With StdInWrite() and StdOutRead() you can pipe things in/out of command line execution, but the special console window just isn't very scriptable. You need to put what you want in a batch file and run that from AutoIt, or better, convert the individual command lines to separate AutoIt functions. For example, instead of sending "net use{ENTER}" to the console window, Run("Net.exe USE") from inside the AutoIt script and use one of the various methods for capturing the output (redirect to a file or hook to STDOUT).

:)

Share this post


Link to post
Share on other sites

Many thanks for your Feedback.I understand the System. For my Dos-Application whit Complex Masks is a litte more tricky but i will try. The Mayor Problem witch I see is, I can run ony one Script (the Application give the Conroll back if this is terminated!

The next Problem is; it is not possible to pipe the Output in the Dosbox. If I start the application with app>mask.txt, the file will be empty an the output go always to the screen!

Bingo. Question can STDOUT capture the real Display Buffer?

Share this post


Link to post
Share on other sites

Many thanks for your Feedback.I understand the System. For my Dos-Application whit Complex Masks is a litte more tricky but i will try. The Mayor Problem witch I see is, I can run ony one Script (the Application give the Conroll back if this is terminated!

The next Problem is; it is not possible to pipe the Output in the Dosbox. If I start the application with app>mask.txt, the file will be empty an the output go always to the screen!

Bingo. Question can STDOUT capture the real Display Buffer?

STDOUT plus STDERR will get everything that goes to the console. Check out the examples in the help file for StdOutRead() and StdErrRead(), plus the comments under Run() for more information. Here is a demo using $STDERR_MERGED to get both STDOUT and STDERR together:
#include <Constants.au3>; For $STDERR_MERGED

Global $PID = Run("net.exe use", @WorkingDir, @SW_MINIMIZE, $STDERR_MERGED)
Global $sStdOut = ""
Do
    $sStdOut &= StdoutRead($PID)
Until @error
MsgBox(64, "Results", $sStdOut)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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