php halt script
I want to do a php script that halts the pc.
how can i do that? i've tried: Code:
<? how can i solve it? thank you! |
Maybe there's a good reason not to call this function from PHP. The permissions for halt on many machines might rest only with the super user. PHP usually doesn't (and shouldn't) run as super user on the server.
|
yes i'm aware of the risk that doing this think implies but i still want to do it. any ideeas on how to do it ?
|
Shouldn't it be
<? system('halt') ?> Also, whomever the apache server is running as, give that user sudo priveledge for halt and then try your code running sudo halt. I'm not sure if it'll work, but its a thought. |
it's the same thing
|
Without knowing your system configuration we're only going to guess why it doesn't work. You haven't even given any error messages (if any) or how PHP is set up in your system. We don't even know whether you're calling this from the command line... I'm assuming you are.
|
ok.... sorry about that.
I have Apache/2.0.55 and PHP/5.1.2 on an Ubuntu Server 6.06. I just want to create a php script with which i want to shutdown the server via my browser. i've created test.php Code:
<? NOTE: as a desperate method i've chmoded /sbin/halt to 777 and it still doesn't work. |
Do you have safe mode enabled? Also, what do your Apache error logs say?
|
in error.log i have:
Code:
halt: must be superuser. |
Like musicman_ace already said you better check out sudo.
|
I thought system commands were called in the scipt through the usage of "print `command`;"?
|
how can i do the sudo thing?
i do a visudo and add the lines: Code:
Cmnd_Alias HALT = /sbin/halt Code:
<? Code:
Passwd: |
Sudo by default requires a password (for the obvious security reasons). If you're absolutely positive that you want to do this, check out the documentation: http://www.courtesan.com/sudo/man/su...swd_and_passwd.
|
:) thank you... solved that. I added the line to /etc/sudoers:
Code:
www-data ALL= NOPASSWD: /sbin/halt |
All times are GMT -5. The time now is 01:34 PM. |