Jump to content
Sign in to follow this  
Steve0

Command Line Interaction

Recommended Posts

Steve0

I've been searching the forum for a while now, but have not had any luck on a number of examples.

I'm trying to run a DOS-based application - which works fine, but I want the script to continue based on the result returned.

Have tried using RunWait() using STDOUT_CHILD and StdoutRead(), but this returns nothing, yet the command runs fine.

When running the same command with the good old "> output.txt" parameter, this works fine, however this does not work through RunWait() or ShellExecute() otherwise I would just interrogate the txt file at the end.

Any other suggestions? The applications I am trying to use are XenCenter's XE.EXE and Putty's PLINK.EXE.

Thanks in advance.

Share this post


Link to post
Share on other sites
enaiman

Of course redirecting the output to a text file works (>)

I guess you have been fooled (like myself) by the fact that the output file needs to have the path specified.

Took me 10 minutes to figure it ..

Here you go:

FileClose(FileOpen("C:\output.txt", 2))
RunWait(@ComSpec & " /c " & 'dir c:\ > c:\output.txt', "", @SW_HIDE) 
ShellExecute("C:\output.txt")
Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Steve0

Thanks for the response.. figured it out; do not use RunWait(), use Run() instead >_<

$ShellText = ''
$Shell = Run('file.exe',@ScriptDir,@SW_HIDE,$STDOUT_CHILD)

While Not @Error
     $ShellText &= StdoutRead($Shell)
Wend

Msgbox(0,"Command Result",$ShellText)
Edited by Steve0

Share this post


Link to post
Share on other sites
bo8ster

RunWait has it's uses and in most cases is safer to use.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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  

×