Jump to content

Parameters to Run


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
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...