Re: [PHP] Start/Stop Service from program php
On Sat, Jul 26, 2008 at 11:48 PM, Micah Gersten [EMAIL PROTECTED] wrote: Generally, apache runs as www-data. What was the output of the command? Actually, Apache generally runs (in order) as nobody, apache, httpd, or daemon. Some distros (such as Ubuntu) or control panel installations (such as Plesk) change this default. For example, Ubuntu Feisty uses 'www-data', and Plesk uses a group of 'psacln'. From PHP, if system access (i.e. - exec(), passthru(), etc.) is allowed, the easiest way to find out which user you are with Apache on *NIX is to run this file in a browser: ?php echo `whoami`; ? -- /Daniel P. Brown Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/Stop Service from program php
Generally, apache runs as www-data. What was the output of the command? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I need write a script execute some command, but try start or stop service like named, network this don't work I edit visudo and add the next lines User_Alias MYGROUP = apache, xyz [EMAIL PROTECTED] wrote: Hi I try execute unsucesfull the next code from web page ?php $cmd1 = shell_exec (sudo /sbin/service named stop); echo $cmd1; ? I need write a script execute some command, but try start or stop service like named, network this don't work I edit visudo and add the next lines User_Alias MYGROUP = apache, xyz Cmnd_Alias MYCOMMAND = /sbin/service %MYGROUP ALL = MYCOMMAND %MYGROUP ALL=(ALL) NOPASSWD: ALL But don't work. Suggest? Thanks ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
David Sveningsson schreef: Hi, I've written an application in c which I would like to start/stop as a daemon in gnu/linux. The application has the argument --daemon which forks the process and exits the parent. Then it setups a SIGQUIT signal handler to properly cleanup and terminate. It also maintains a lockfile (with the pid) so only one instance is allowed. So, to start this application I created a php site that calls exec(/path/to/binary --daemon /dev/null 2 /dev/null). Everything is working so far, but I cannot get the application to receive the SIGQUIT when I start using php and exec. Not even manually using kill in the shell. It works correctly if I start manually thought. So, is this possible to do? Doesn't exec allow applications with signal handlers? Is there some other way to terminate the application? there is nothing special about exec that makes working with the kill command different to anything else, though you might take a look at the posix_kill() command instead. e.g. posix_kill(`cat /path/to/pidfile`, SIGQUIT); you say you can't even send SIGQUIT to the daemon using kill on the command line, this suggests the problem lies in the fact that the daemon's signal handler is not actually working (when the process is daemonized). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
David Sveningsson wrote: Hi, I've written an application in c which I would like to start/stop as a daemon in gnu/linux. The application has the argument --daemon which forks the process and exits the parent. Then it setups a SIGQUIT signal handler to properly cleanup and terminate. It also maintains a lockfile (with the pid) so only one instance is allowed. So, to start this application I created a php site that calls exec(/path/to/binary --daemon /dev/null 2 /dev/null). Everything is working so far, but I cannot get the application to receive the SIGQUIT when I start using php and exec. Not even manually using kill in the shell. It works correctly if I start manually thought. So obviously something is catching the SIGQUIT before it gets to your daemon. You mention a php site, so I take it you're running apache. In an apache process you then do an exec(something). I think apache is probably taking care of the SIGQUIT. So, is this possible to do? Doesn't exec allow applications with signal handlers? Is there some other way to terminate the application? Why do you have to kill it with an explicit signal - why not not have a way of communicating with the process that'll make it terminate when you raise a flag or send it a message or something. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
Hi, You might consider D-BUS for your application and the D-BUS PHP binding which is available since some days too. This would allow you to start / stop your C application in a far more secure way than the suggested one. Please have a look at my original release annoucement at the D-BUS mailing list: http://lists.freedesktop.org/archives/dbus/2008-February/009363.html as well as the download URL: https://sourceforge.net/project/showfiles.php?group_id=17176package_id=68954 Even if the application runs on Windows you might be able to use D-BUS for communication. Daniel Brown schrieb: On Wed, Feb 27, 2008 at 7:51 AM, David Sveningsson [EMAIL PROTECTED] wrote: Hi, I've written an application in c which I would like to start/stop as a daemon in gnu/linux. The application has the argument --daemon which forks the process and exits the parent. Then it setups a SIGQUIT signal handler to properly cleanup and terminate. It also maintains a lockfile (with the pid) so only one instance is allowed. So, to start this application I created a php site that calls exec(/path/to/binary --daemon /dev/null 2 /dev/null). You can (and should) write this out like so: ? exec(/path/to/binary --daemon /dev/nul 21,$ret,$err); ? The means to append to the end of a file. You can use on /dev/null, since it's not a file, but just a black hole, but you may want to get into the habit of redirecting and appending. The 21 redirects channel 2 (STDERR) to channel 1 (STDOUT) so that all output in this case is sent to /dev/null. For any output that would otherwise be generated, $ret will hold STDOUT data, and $err will hold the STDERR code. Everything is working so far, but I cannot get the application to receive the SIGQUIT when I start using php and exec. Not even manually using kill in the shell. It works correctly if I start manually thought. So, is this possible to do? Doesn't exec allow applications with signal handlers? Is there some other way to terminate the application? You may want to launch it from a BASh script. I had written out an example for someone on this list at the beginning of the month. Feel free to check it out and use it, or use any part of it: [Download] http://pilotpig.net/code-library/daemonize.sh [View Source] http://pilotpig.net/code-library/source.php?f=daemonize.sh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
On Wed, Feb 27, 2008 at 7:51 AM, David Sveningsson [EMAIL PROTECTED] wrote: Hi, I've written an application in c which I would like to start/stop as a daemon in gnu/linux. The application has the argument --daemon which forks the process and exits the parent. Then it setups a SIGQUIT signal handler to properly cleanup and terminate. It also maintains a lockfile (with the pid) so only one instance is allowed. So, to start this application I created a php site that calls exec(/path/to/binary --daemon /dev/null 2 /dev/null). You can (and should) write this out like so: ? exec(/path/to/binary --daemon /dev/nul 21,$ret,$err); ? The means to append to the end of a file. You can use on /dev/null, since it's not a file, but just a black hole, but you may want to get into the habit of redirecting and appending. The 21 redirects channel 2 (STDERR) to channel 1 (STDOUT) so that all output in this case is sent to /dev/null. For any output that would otherwise be generated, $ret will hold STDOUT data, and $err will hold the STDERR code. Everything is working so far, but I cannot get the application to receive the SIGQUIT when I start using php and exec. Not even manually using kill in the shell. It works correctly if I start manually thought. So, is this possible to do? Doesn't exec allow applications with signal handlers? Is there some other way to terminate the application? You may want to launch it from a BASh script. I had written out an example for someone on this list at the beginning of the month. Feel free to check it out and use it, or use any part of it: [Download] http://pilotpig.net/code-library/daemonize.sh [View Source] http://pilotpig.net/code-library/source.php?f=daemonize.sh -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
@4u skrev: Hi, You might consider D-BUS for your application and the D-BUS PHP binding which is available since some days too. This would allow you to start / stop your C application in a far more secure way than the suggested one. Please have a look at my original release annoucement at the D-BUS mailing list: http://lists.freedesktop.org/archives/dbus/2008-February/009363.html as well as the download URL: https://sourceforge.net/project/showfiles.php?group_id=17176package_id=68954 D-BUS sounds excellent, I will definitely try it out. I have never coded D-BUS myself but I don't think it would be too hard. Even if the application runs on Windows you might be able to use D-BUS for communication. Currently neither the application or the frontend is planned to support windows as it is already full of very unix specific code. -- //*David Sveningsson [eXt]* Freelance coder | Game Development Student http://sidvind.com Thou shalt make thy program's purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
Per Jessen skrev: David Sveningsson wrote: Hi, I've written an application in c which I would like to start/stop as a daemon in gnu/linux. The application has the argument --daemon which forks the process and exits the parent. Then it setups a SIGQUIT signal handler to properly cleanup and terminate. It also maintains a lockfile (with the pid) so only one instance is allowed. So, to start this application I created a php site that calls exec(/path/to/binary --daemon /dev/null 2 /dev/null). Everything is working so far, but I cannot get the application to receive the SIGQUIT when I start using php and exec. Not even manually using kill in the shell. It works correctly if I start manually thought. So obviously something is catching the SIGQUIT before it gets to your daemon. You mention a php site, so I take it you're running apache. In an apache process you then do an exec(something). I think apache is probably taking care of the SIGQUIT. Yes, I am using apache (forgot to mention it). Is there a way to stop apache from catching the signals? So, is this possible to do? Doesn't exec allow applications with signal handlers? Is there some other way to terminate the application? Why do you have to kill it with an explicit signal - why not not have a way of communicating with the process that'll make it terminate when you raise a flag or send it a message or something. Currently I have no other way of communicating than a mysql database (it passes data that needs processing) so I thought it would be quick and easy to just raise a signal. I read in another mail about D-BUS which I think would be a better way of communication. /Per Jessen, Zürich -- //*David Sveningsson [eXt]* Freelance coder | Game Development Student http://sidvind.com Thou shalt make thy program's purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start/stop daemon using php
David Sveningsson wrote: Per Jessen skrev: So obviously something is catching the SIGQUIT before it gets to your daemon. You mention a php site, so I take it you're running apache. In an apache process you then do an exec(something). I think apache is probably taking care of the SIGQUIT. Yes, I am using apache (forgot to mention it). Is there a way to stop apache from catching the signals? Hmm, when your daemon does a fork(), it should be perfectly capable of installing its own signal handlers. Is SIGQUIT enabled? Check your signal mask. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] start/stop deamon
[snip] can some body tell me how to start/stop a deamon ( eg: dhcpd ) from php ? and also can v apply that same method to start/stop a some script by php ? [/snip] http://www.php.net/exec
[PHP] RE : [PHP] Start php-script with exec()?
Maybe you'll need to add /dev/null at the end of your execution command. Adding this will put your script to background and php wouldn't wait for this script end before terminate http process (= no browser timeout). For example : exec(/logiciel/php/bin/php /tmp/toto.php /dev/null ); Cordialement, Jean-Philippe BENARD Consultant STERIA Infogérance ([EMAIL PROTECTED]) -Message d'origine- De : Victor Spång Arthursson [mailto:[EMAIL PROTECTED] Envoyé : lundi 22 septembre 2003 14:16 À : [EMAIL PROTECTED] Objet : [PHP] Start php-script with exec()? Is it possible? I have a file that takes 5 minutes to run, and I would like to be able to start it when loading a page. But I can't include it because it forces the browser to timeout exec(script.php) doesn't seem to work Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Start php-script with exec()?
[snip] Is it possible? I have a file that takes 5 minutes to run, and I would like to be able to start it when loading a page. But I can't include it because it forces the browser to timeout... exec(script.php) doesn't seem to work... [/snip] exec needs a little more information, and will the exec'd script need to return information to the browser? exec(php script.php); will run the script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
måndagen den 22 september 2003 kl 14.31 skrev Jay Blanchard: exec(php script.php); will run the script. How does this look on a OSX/UNIX system? Can the path to php be found in a system variable, for convinience and portability of the script? Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Start php-script with exec()?
[snip] måndagen den 22 september 2003 kl 14.31 skrev Jay Blanchard: exec(php script.php); will run the script. How does this look on a OSX/UNIX system? Can the path to php be found in a system variable, for convinience and portability of the script? [/snip] As usual for *nix type 'which php' which will return the path to the PHP executable. For portability you could then do something to the effect of (not tested) $pathPHP = exec(which php); exec($pathPHP script.php); If you know the path to PHP you can include a bash line at the top of the script and remove the php call from the exec. #!/usr/local/bin/php //(top line of script) exec(script.php); See http://www.php.net/manual/en/features.commandline.php for more details -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
måndagen den 22 september 2003 kl 14.52 skrev Jay Blanchard: As usual for *nix type 'which php' which will return the path to the PHP executable. For portability you could then do something to the effect of (not tested) which() doesn't resolve the path, but I found out it was /usr/local/php/bin/php. But how do I make the call exec(/usr/local/php/bin/php process1.php); so that the page from which the call is made doesnt wait for the result but instead just continues? Sincerely, Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Start php-script with exec()?
[snip] As usual for *nix type 'which php' which will return the path to the PHP executable. For portability you could then do something to the effect of (not tested) which() doesn't resolve the path, but I found out it was /usr/local/php/bin/php. But how do I make the call exec(/usr/local/php/bin/php process1.php); so that the page from which the call is made doesnt wait for the result but instead just continues? [/snip] use (not tested, but runs other processes as background processes) exec(/usr/local/php/bin/php process1.php ); From http://www.php.net/exec : If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
exec(/usr/local/php/bin/php process1.php ); process executes in the background Victor Spång Arthursson wrote: måndagen den 22 september 2003 kl 14.52 skrev Jay Blanchard: As usual for *nix type 'which php' which will return the path to the PHP executable. For portability you could then do something to the effect of (not tested) which() doesn't resolve the path, but I found out it was /usr/local/php/bin/php. But how do I make the call exec(/usr/local/php/bin/php process1.php); so that the page from which the call is made doesnt wait for the result but instead just continues? Sincerely, Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
mndagen den 22 september 2003 kl 15.04 skrev Jay Blanchard: use (not tested, but runs other processes as background processes) exec(/usr/local/php/bin/php process1.php ); Think that works as well; my solution was /dev/null Now the big question is if I will get it to work on a windows-server using exec(php script.php args NUL) ;) Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
Ok, it works fine on my development server with Mac OS X. But the hosting server seems to be WinNT, and on this it doesnt work. Anyone who can help me with some standard paths to php.exe? c:\php\ Doesnt work ;) Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
Ask your hosting company. Are you sure they will allow you to execute commands? Check phpinfo - safe mode and disabled functions. Victor Spång Arthursson wrote: Ok, it works fine on my development server with Mac OS X. But the hosting server seems to be WinNT, and on this it doesnt work. Anyone who can help me with some standard paths to php.exe? c:\php\ Doesnt work ;) Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Start php-script with exec()?
måndagen den 22 september 2003 kl 16.11 skrev Marek Kilimajer: Ask your hosting company. Are you sure they will allow you to execute commands? Check phpinfo - safe mode and disabled functions. Asked them and they told it was a mistake we had php on the server - according to them it was either php OR asp. I quickly thanked and hung up. So now the question stands to you folks on this list ;) Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Start / Stop
Timestamp it at the beginning and the end. Bruce Karstedt President Technology Consulting Associates, Ltd. Tel: 847-735-9488 Fax: 847-735-9474 -Original Message- From: Chris Kay [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 6:57 PM To: PHP General List Subject: [PHP] Start / Stop Importance: Low Anyone have some tips on the best way to make a Script started @ 5:45pm Script ended @ 5:50pm Script? --- Chris Kay Technical Support - Techex Communications Website: www.techex.com.au Email: [EMAIL PROTECTED] Telephone: 1300 88 111 2 - Fax: (02) 9970 5788 Address: Suite 13, 5 Vuko Place, Warriewood, NSW 2102 Platinum Channel Partner of the Year - Request DSL - Broadband for Business --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] start
On Fri, 3 Jan 1997, El Ucalito wrote: im introducing to php and i need to know (under windows98) if are free /and where can i download it/ the software needed to program and test php4 www.php.net will answer all. -- 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]
RE: [PHP] Start you php script over??
Is there a way for me to tell my php script to start over? I want to have an if then statement to check if something is done. Then if it isn't I want the php script to start over. header( "location: $PHP_SELF" ); OR header( "location: $REQUEST_URI" ); if you are using a query string/GET variables Chris
Re: [PHP] Start you php script over??
header() ?php if ($done) ... else { header("Location: http://$SERVER_NAME/$PHP_SELF"); exit(); } ? i your using sessions without coookies. header("Location: http://$SERVER_NAME/$PHP_SELF?PHPSESSID=$PHPSESSID"); -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Brandon Orther"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is there a way for me to tell my php script to start over? I want to have an if then statement to check if something is done. Then if it isn't I want the php script to start over. Thank you, Brandon Orther WebIntellects Design/Development Manager [EMAIL PROTECTED] 800-994-6364 www.webintellects.com -- 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]