schoel Posted April 24, 2009 Posted April 24, 2009 Hello, I need a script to run a console program for me that requires parameters. I am aware of the ShellExecution function but I also need to get the output from the program (from stdout) and I can't find any way to get that. Can anyone help me? Best regards, Schoel
Developers Jos Posted April 24, 2009 Developers Posted April 24, 2009 Hello,I need a script to run a console program for me that requires parameters. I am aware of the ShellExecution function but I also need to get the output from the program (from stdout) and I can't find any way to get that. Can anyone help me?Best regards,SchoelWhat have you tried and isn't working ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
schoel Posted April 24, 2009 Author Posted April 24, 2009 I actually just read the help file and from that it wasn't clear that Run can actually pass parameters to the program in the filename paramater. I have however tried this now: #include <Constants.au3> $gocr = Run("C:\Program\NetPbm\bin\gocr047.exe -i C:\Program\NetPbm\bin\test.pnm", "C:\Program\NetPbm\bin\", @SW_MAXIMIZE, 2) While 1 $line = StdoutRead($gocr) If @error Then ExitLoop WEnd MsgBox(0, "STDOUT read:", $line) When I run gocr047 with the same parameters (-i C:\Program\NetPbm\bin\test.pnm) in a console, I get some output on standard out and then the program terminates. The above script however, shows just an empty MsgBox. Any ideas?
PsaltyDS Posted April 24, 2009 Posted April 24, 2009 I actually just read the help file and from that it wasn't clear that Run can actually pass parameters to the program in the filename paramater. I have however tried this now: #include <Constants.au3> $gocr = Run("C:\Program\NetPbm\bin\gocr047.exe -i C:\Program\NetPbm\bin\test.pnm", "C:\Program\NetPbm\bin\", @SW_MAXIMIZE, 2) While 1 $line = StdoutRead($gocr) If @error Then ExitLoop WEnd MsgBox(0, "STDOUT read:", $line) When I run gocr047 with the same parameters (-i C:\Program\NetPbm\bin\test.pnm) in a console, I get some output on standard out and then the program terminates. The above script however, shows just an empty MsgBox. Any ideas? You are overwriting the variable vice appending the data. Change this: Global $line = "" While 1 $line &= StdoutRead($gocr) If @error Then ExitLoop WEnd 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
Richard Robertson Posted April 24, 2009 Posted April 24, 2009 (edited) $line &= StdoutRead($gocr)If you only use =, you just get the last line.Edit: Curses, foiled again. Edited April 24, 2009 by Richard Robertson
schoel Posted April 24, 2009 Author Posted April 24, 2009 Thank you both for your help and time! It works properly now! Copied the While loop from the example of StdoutRead.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now