Sign in to follow this  
Followers 0
darzanmihai

shellexecute question

11 posts in this topic

#1 ·  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.

Share this post


Link to post
Share on other sites



I know very little about this, but I would guess that you would need to use the Run() function rather than shellexecute in order to get the PID of the programm you are running, then you want to be looking at StdoutRead().


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

may be it give an error code...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

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  
Followers 0