Jump to content

Recommended Posts

Posted

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
Posted

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

What 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.
  :)

Posted

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?

Posted

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
Posted

Thank you both for your help and time! It works properly now!

Copied the While loop from the example of StdoutRead.

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
×
×
  • Create New...