Jump to content

Recommended Posts

Posted (edited)

I want to shellexecute with parameters a file that will convert a database to excel, but sometimes the database is corupt or is of another type and then it displays an error message in the comand prompt window and it stays this way unlimited time.

What I want to do is read the messages that the database converter outputs in the command prompt window so that I know if it succeded or failed.

Could someone please guide me?

Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Posted (edited)

Hi,

have a look in helpfile at StdoutRead example.

Built you Run command with the params you need to execute your conversion exe.

If you need to masquerade you params with ", have a look in helpfile -> Language Reference -> Datatypes: Strings

If you need further help, come back.

;-))

Stefan

@JohnOne beats me...

Edited by 99ojo
Posted

Use "Run" and set "opt_flag" to "$STDOUT_CHILD".

With "StdOutRead" you can get the output of your program. See the helpfile for "StdOutRead". There you'll find an example.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 5/21/2010 at 9:15 AM, '99ojo said:

Hi,

have a look in helpfile at StdoutRead example.

Built you Run command with the params you need to execute your conversion exe.

If you need to masquerade you params with ", have a look in helpfile -> Language Reference -> Datatypes: Strings

If you need further help, come back.

;-))

Stefan

@JohnOne beats me...

Thx all for help. I tied the code:

$hdl = Run(@ComSpec & " /c " &"paradox-dbase-reader.exe -c -i "&$FilePath&"\"&$table_list[$i]&".db -o "&@ScriptDir&"\Export_temp\ -f excel",@ScriptDir,@SW_SHOW,$STDOUT_CHILD)
$line=""
While 1
    $line = StdoutRead($hdl)
    If @error Then ExitLoop
    If $line<>"" Then ConsoleWrite($line&@CRLF)
Wend

but the stdout returns nothing...

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Posted

  On 5/21/2010 at 10:14 AM, 'darzanmihai said:

Thx all for help. I tied the code:

$hdl = Run(@ComSpec & " /c " &"paradox-dbase-reader.exe -c -i "&$FilePath&"\"&$table_list[$i]&".db -o "&@ScriptDir&"\Export_temp\ -f excel",@ScriptDir,@SW_SHOW,$STDOUT_CHILD)
Consolewrite("Hdl: " & $hdl & ", Error: " & @error & @CRLF)
$line=""
While 1
    $line = StdoutRead($hdl)
    If @error Then ExitLoop
    If $line<>"" Then ConsoleWrite($line&@CRLF)
Wend

but the stdout returns nothing...

You don't specify a path where the exe should reside.

I added a ConsoleWrite after the Run to check if the processId is returned. If $Hdl = 0 then the exe hasn't been started successfully.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 5/21/2010 at 10:48 AM, 'water said:

You don't specify a path where the exe should reside.

I added a ConsoleWrite after the Run to check if the processId is returned. If $Hdl = 0 then the exe hasn't been started successfully.

the cmd line executable resides in the same folder as the script, but anyway I modified the code:

$hdl = Run(@ComSpec & " /c " &@ScriptDir&"\paradox-dbase-reader.exe -c -i "&$FilePath&"\"&$table_list[$i]&".db -o "&@ScriptDir&"\Export_temp\ -f excel",@ScriptDir,@SW_SHOW,$STDOUT_CHILD)
        Consolewrite("Hdl: " & $hdl & ", Error: " & @error & @CRLF)
        $line=""
        While 1
            $line = StdoutRead($hdl)
            If @error Then ExitLoop
            If $line<>"" Then ConsoleWrite($line&@CRLF)
        Wend

The executable is runed corectly and it does its job, but I cannot catch its output on the command prompt window... the StdoutRead() returns nothing

I need to catch what it returns on the command prompt in order to know if it has finished - see picture post-36572-12747763341797_thumb.jpg - or it has an error (because if it finishes it stays open).

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Posted

  On 5/25/2010 at 11:09 AM, 'wakillon said:

Instead of StdoutRead try with StderrRead ( don't forget $STDERR_CHILD )

may be it give an error code...

...Nothing.....absolutelly nothing. It returns "". The only thing it returns is "^C" when I manually close the cmd window.

Do you have another ideea, please?

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Posted

  On 5/26/2010 at 11:00 AM, 'darzanmihai said:

...Nothing.....absolutelly nothing. It returns "". The only thing it returns is "^C" when I manually close the cmd window.

Do you have another ideea, please?

I get the impression that the exe doesn't write to StdOut. Maybe it's a kind of GUI that mimics a console.

Could you start AutoIt's WindowInfo tool and check if you get any results? Use the Finder Tool (crosshair icon) and point to the Paradox Database window.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 5/26/2010 at 11:17 AM, 'water said:

I get the impression that the exe doesn't write to StdOut. Maybe it's a kind of GUI that mimics a console.

Could you start AutoIt's WindowInfo tool and check if you get any results? Use the Finder Tool (crosshair icon) and point to the Paradox Database window.

Au3info returns nothing. This is a CUI. Anyway I resolved the issue, by using another cmd line parameter -e to exit after finishes....:mellow: I'm so dumb I didn't saw it in the first place.

Thx anyway for the effort

Mihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...