Windows Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsWindows Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 30th, 2003, 03:48 PM
txgirlta txgirlta is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 txgirlta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question DESPERATE!!!! How do I use PHP system() command (or something else?) on XP?

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













Reply With Quote
  #2  
Old September 30th, 2003, 07:22 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 44 m 44 sec
Reputation Power: 174
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


Reply With Quote
  #3  
Old September 30th, 2003, 07:37 PM
Sepodati's Avatar
Sepodati Sepodati is online now
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 72870 Folding Title: Intermediate FolderFolding Points: 72870 Folding Title: Intermediate FolderFolding Points: 72870 Folding Title: Intermediate FolderFolding Points: 72870 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 20 h 22 m 9 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Moved to Windows Forum...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsWindows Help > DESPERATE!!!! How do I use PHP system() command (or something else?) on XP?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT