[PHP] Re: exec/system question..
Bruce wrote: hey... looking at initiating a perl app from inside a php web app. basically, the user will hit a button/start the app...the perl script will take awhile to complete, so i'd like to run the app and then continue on with the php process... so my question boils down to what's the best approach. 1) i could run the perl app, and wait until it finishes, and then continue with the logic. the app will use the results of the perl script and stuff it into a db/tbl, so i need to get the results of the perl app. 2) i could run the perl script, and have it somehow run in the background this would ba good, if there's a way to essentially run the php script in the background such that it doesn't hang apache. i'd like to kick off the php, and have the php/web app return. i could set some form of session var to trigger off of when the php is complete.. any thoughts/pointers/etc... thanks -bruce What you are trying to do (from my understanding) is called forking. Forking is a primitive means of threading your PHP application. There is a great tutorial called Fork PHP! at the forums where I am a moderator, (you should check them out sometime :D): http://www.phpfreaks.com/tutorials/71/0.php Let us know if this is of any help to you. ~ Kevin Arenium M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: exec(), system() and :(
Thank for your reply BUT the solution you proposed me does NOT apply, because eval() is for evaluating strings as if they were codes, moreover the somescript.php would have to be readapted : please note that the script takes the arguments via argc (commandline arguments). Eval() is not suitable for running external (and may be big) script file which takes in input the arguments via $HTTP_SERVER_VARS['argv']; otherwise I would have used include() !! The problem is open: the behaviour that I stated below is very strange... could not understand why... Siva To: [EMAIL PROTECTED] From: elias [EMAIL PROTECTED] Date: Tue, 10 Jul 2001 08:45:51 -0700 Subject: Re: exec(), system() and Hmm... why don't try to use eval() read the PHP file from within your PHP script and eval the read file, Siva Subraj [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear list, I have a strange problem with the weird behaviour of exec() or system() When I do: exec('/usr/local/bin/php somescript.php if=infile.txt of=outfile.txt out_somescript '); in a script invoked by apache, it works perfectly - the somescript processes 'infile.txt' and produces 'outfile.txt' . BUT, if I take off the ampersand '' (ie I want to exec it and to wait for it to finish before going ahead), it does NOT work. I find an empty file 'out_somescript' and no 'outfile.txt' at all. I recompiled php (ELF binary in /usr/local/bin) without --enable-force-cgi-redirect --enable-safe-mode --enable-discard-path All files have universal read permission, the directory is writable by apache group. There is suExec module. I also tried system() to make a shell invocation. The problem persists: with it's ok, meanwhile without it doesn't execute the script. What is wrong? Please help me, thanks!! Siva -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: exec(), system() and
Hmm... why don't try to use eval() read the PHP file from within your PHP script and eval the read file, Siva Subraj [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear list, I have a strange problem with the weird behaviour of exec() or system() When I do: exec('/usr/local/bin/php somescript.php if=infile.txt of=outfile.txt out_somescript '); in a script invoked by apache, it works perfectly - the somescript processes 'infile.txt' and produces 'outfile.txt' . BUT, if I take off the ampersand '' (ie I want to exec it and to wait for it to finish before going ahead), it does NOT work. I find an empty file 'out_somescript' and no 'outfile.txt' at all. I recompiled php (ELF binary in /usr/local/bin) without --enable-force-cgi-redirect --enable-safe-mode --enable-discard-path All files have universal read permission, the directory is writable by apache group. There is suExec module. I also tried system() to make a shell invocation. The problem persists: with it's ok, meanwhile without it doesn't execute the script. What is wrong? Please help me, thanks!! Siva -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]