Hi
I am trying to run an executable by passing the name of exe with all the parameters to a subroutine. I don't have any idea how to check the status in perl. I am not sure about system() and exec() as they won't be returning the output. The code in vbscript is
Function ExecSyncStep(stepName)
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(stepName)
Dim ouputStream
ouputStream = ""
Do While oExec.Status = 0
Do While Not oExec.StdOut.AtEndOfStream
ouputStream = ouputStream & oExec.StdOut.ReadAll
Loop
WScript.Sleep 100
Loop
Do While Not oExec.StdOut.AtEndOfStream
ouputStream = ouputStream & oExec.StdOut.ReadAll
Loop
Set ExecSyncStep = oExec
End Function
I came up with this
#Returns the status object of the sync process
$oExec;
$oExec = system($stepName);
$ouputStream = "";
while($? eq 0){
Do While Not oExec.StdOut.AtEndOfStream
ouputStream = ouputStream & oExec.StdOut.ReadAll
Loop
sleep 100;
}
Do While Not oExec.StdOut.AtEndOfStream
ouputStream = ouputStream & oExec.StdOut.ReadAll
Loop
#WScript.StdOut.Write ouputStream
return $oExec;
}
Please advise.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.