Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Read error from Run command
Message
From
21/11/2002 18:50:25
 
 
To
20/11/2002 12:48:44
Vicki Miles
Vlm International, Inc.
Mishawaka, Indiana, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00721753
Message ID:
00725537
Views:
14
>Ed,
>
>I'm using your api_apprun to run a command that returns and errors as a string returned to the console. I've changed the apirun.iccommandline to include " > error.txt". As soon as I do, nothing happens. The return result remains true, but the command is no longer executed. Nor is any error.txt file produced.
>
>As soon as I take the " > error.txt" out, then it works fine again. But, of course, now I can't read any possible error conditions.

I suspect that error.txt -is- produced; you're porting the output of the STDOUT port, not STDERR, to error.txt. That should hold anything written to the console under normal circumstances. But a write to STDERR may not be routed via STDOUT, so the simple > redirection may not be adequate. One of the structures in the API call can be used to redirect any of the three standard ports (STDIN, STDOUT and STDERR) to a file handle opened by the parent app - you'd have to hack the code, or wait until I make that particular hack; the new version should be posted in a couple of days anyway to permit priority control, impersonation and remoted execution; I found a bug in my CreateRemoteProcess() code in WhilFest that needs to be fixed before the release.

A DOS app that runs returns success to API_APPRUN; however, it reports its success/failure through a termination code. This is a numeric code that used to drive the DOS command window ERRORLEVEL. You can retrieve that error code from a launched app via the CheckProcessExitCode() method; it will return a 259 if the process is still running, a 0 if it terminated normally, and any other numeric value represents an error condition reported at termination by the DOS application. If you use LaunchAppAndWait() to run the app; you can grab the termination code any time after the return from LaunchAppAndWait() by calling the CheckProcessExitCode() method until (1) you release the object, or (2) you perform a subsequent launch operation from the same object. If you use LaunchApp to run asynchronously, you can use CheckProcessExitCode() to poll for termination as well as to retrieve the termination code; once the app stops running, the value remains static until one of the preceding actions are taken.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform