Jump to content

shellexecute question


Recommended Posts

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.

Link to comment
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.

Link to comment
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...

Edited by 99ojo
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

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