|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello all,
I've been searching ALL over net and can't seem to find the answer to my particular problem. First of all, I am a newbie to PHP. I am writing a web app which ultimately executes an external program (call it tester.exe) on Windows XP, then goes on and does other things as a web app. There are two problems I am trying to solve: (1) tester.exe wants to pop up an output window to print stdout and stderr statements. This seems to hang the script when running it in the browser. My workaround was to redirect the stdout and stderr to a file (not what I want to do - but - it works, so ok)...so, this leads to the second problem.... (2) After I have stdout/stderr redirected to a file, tester.exe needs to run for about 1 minute wall clock time....the script times out while it is running (I get the message:Expiries timeout! , etc...). What command (obviously not system()!) can I use to run tester.exe in the background, ie. set it running, but don't wait for it to finish? I want for control to return to the next PHP statement after PHP does whatever command it needs to do (again, obviously not system()!) to execute tester.exe, so that I can go on and do other things while tester.exe is running in the background. Seems like such an easy thing to do in Unix, not so in XP? I would REALLY like for option(1) to work (i.e. how do I get my external program to execute under PHP and have it pop up a window for stdout/stderr to write to).... However, if I could get (2) (where stdout/err gets redirected to a file) to work (i.e. how to run an external program in 'background' from PHP on XP), that would be ok too....In unix, this is simple...just do a '&'....how to do it on XP? the current PHP code I'm using (for approach (2)- redirecting stdout/stderr and using system(), which is causing the script to 'timeout') is: <?php // Do the submit here function execInBackground($path, $exe, $args = "") { if (file_exists($path . $exe)) { chdir($path); if (substr(php_uname(), 0, 7) == "Windows"){ system("$exe >>output.log 2>&1",$rvalue); echo "after system call, returnvalue=[$rvalue]<br>"; } else { exec("./" . $exe . " " . escapeshellarg($args) . " > /dev/null &"); } } else { echo ("path[$path.$exe] did not exist<br>"); } } execInBackground("C:\\Projects\\","tester.exe"); ?> Thanks so much for any help....I've been scratching my head on what should be a really simple task! I feel stupid!!!! ![]() |
|
#2
|
||||
|
||||
|
I think that the issue is w/ the commands you're sending to Windows, not the system() function. I would research the DOS commands equivalent to the shell commands you're using.
__________________
Give a person code, and they'll hack for a day; Teach them how to code, and they'll hack forever. Analyze twice; hack once. The world's first existential ITIL question: If a change is released into production without a ticket to track it, was it actually released? About DrGroove: ITIL-Certified IT Process Engineer - Enterprise Application Architect - Freelance IT Journalist - Devshed Moderator - Funk Bassist Extraordinaire |
|
#3
|
||||
|
||||
|
Moved to Windows Forum...
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Windows Help > DESPERATE!!!! How do I use PHP system() command (or something else?) on XP? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|