note 53997 added to function.popen

From: Date: Mon, 20 Jun 2005 13:26:15 +0000
Subject: note 53997 added to function.popen
Groups: php.notes 
Request: Send a blank email to php-notes+get-90691@lists.php.net to get a copy of this message
If you want to fork a process under windows, this is the function to use. I created a batch file called runcmd.bat with the following line start %1 %2 %3 %4 then I have the folowing function <? define('RUNCMDPATH', 'c:\\htdocs\\nonwebspace\\runcmd.bat'); function runCmd($cmd) { $externalProcess=popen(RUNCMDPATH.' '.$cmd, 'r'); pclose($externalProcess); } ?> with this, doing something like <? runCmd('php.exe printWorkOrder.php 3498'); ?> will launch php.exe outside of apache and allow the script calling the runCmd() function to continue without waiting for the command line process to return. The process will run under the same user account that Apache (or whatever webserver you're running) is running under, so make sure it has permissions to do whatever you need to do. Also, make sure that the batch file has enough %n s in order to pass all the command line variables that you might need to pass. Special thanks to kicken from the devshed forums for coming up with the idea. ---- Manual Page -- http://www.php.net/manual/en/function.popen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53997 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53997&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53997&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90691) next »