Asheeown Posted August 31, 2008 Share Posted August 31, 2008 Okay, primary goal here is this: User views a page that executes a background php script that continuously pulls data from a certain source and loads it into the database. Two things I am having problems with 1. The script won't execute I am doing a simple script output to a text file and it doesn't show but works in command prompt 2. I cannot seem to figure out how to get the PID of the php process running. Installation structure is xampp full installation so phhp is under the xampp folder, this is not the structure for my real server, is is a server 2008 server with fastcgi php installed. Here is the code I am using to execute the file <?php $Command = exec("C:\xampp\php\php.exe C:\xampp\php\myscript.php > output.txt"); echo $Command; ?> Link to comment https://forums.phpfreaks.com/topic/122154-background-process/ Share on other sites More sharing options...
Asheeown Posted September 1, 2008 Author Share Posted September 1, 2008 Okay figured out why it's not starting, needed forward instead of backslashes. However it sits at loading on the page, I need it to be completely in the background so that the web page is completely unaffected by the execution. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-630658 Share on other sites More sharing options...
Asheeown Posted September 3, 2008 Author Share Posted September 3, 2008 Okay been a few days so I guess I'll bump it. The problem I am having is the page that is loading the background process is hanging at loading, it's trying to incorporate the background process in the page which I don't want to happen. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633220 Share on other sites More sharing options...
DarkWater Posted September 3, 2008 Share Posted September 3, 2008 This is why we use cron and don't even fathom using Windows, Fearsoldier. >_< If you want it to not hang, you need to redirect output to another file, which I don't think Windows on CMD can do with the > like Linux can. And on Linux, if you needed the data afterwards, you could always use a named pipe. =P Good luck getting this to run on Windows. I'd check on how to redirect output on CMD. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633223 Share on other sites More sharing options...
Asheeown Posted September 3, 2008 Author Share Posted September 3, 2008 The process works fine in CMD. It executes directly into output.txt and the important thing it does not hang on the process it automatically returns to a new line but the process is still running in the background. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633226 Share on other sites More sharing options...
DarkWater Posted September 3, 2008 Share Posted September 3, 2008 And you're positive that nothing gets written to STDIN? >_< Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633228 Share on other sites More sharing options...
Asheeown Posted September 3, 2008 Author Share Posted September 3, 2008 Yes It works for command prompt using the EXACT same execution as I use in the PHP. Php has to have a way to not want any output or maybe an alternative way would do? This is a user triggered script so when a user browses to this page it's going to start, I can't have it hung up in the background. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633233 Share on other sites More sharing options...
DarkWater Posted September 3, 2008 Share Posted September 3, 2008 Okay, I don't think I can offer any more help on this because I'm not a Windows user, so I'm not too sure how PHP functions with exec() on Windows. Try Googling for similar problems I guess. D: Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633237 Share on other sites More sharing options...
Asheeown Posted September 3, 2008 Author Share Posted September 3, 2008 Well if anyone could point me in the direction of a COM tutorial I have seen that they can execute processes but have yet to see an example or even an explanation for that matter. Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633252 Share on other sites More sharing options...
Asheeown Posted September 4, 2008 Author Share Posted September 4, 2008 Well before I sign off tonight I figure I should post my new code, this code is working, but isn't working lol. <?php $dir = "C:/xampp/php"; $php_path = "C:/xampp/php/php.exe"; $file = "myscript.php"; $cmd_options = "-t " . time(); $wscript = new COM('WScript.Shell'); echo $wscript->Run("cmd /K CD $php_path $dir/$file > output.txt & ", 0, false); ?> Replicated it completely in Windows and I get an Access is Denied read out. Vista kills me but Windows Server 2008 does the same access bull**** so does anyone know how to setup permissions so that it won't require admin access? Or any other hints perhaps? Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633303 Share on other sites More sharing options...
lanmonkey Posted September 4, 2008 Share Posted September 4, 2008 this probably has somthing to do with vista's new securit that prevents scripts doing stuff in the background. try disabling the security center service in control panel Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633487 Share on other sites More sharing options...
Asheeown Posted September 4, 2008 Author Share Posted September 4, 2008 Success! I got it working, OK one more question, the com_get to pull a property from a COM object has been deprecated in PHP5. I need to pull the process ID from the execution I am running. $dir = "C:/xampp/php"; $php_path = "C:/xampp/php/php.exe"; $file = "myscript.php"; $cmd_options = "-t " . time(); $wscript = new COM('WScript.Shell'); $Command = $wscript->Run("$php_path $dir/$file", 0, false); Link to comment https://forums.phpfreaks.com/topic/122154-background-process/#findComment-633776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.