PHP code - > system('init 6'); as root ?

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

PHP code - > system('init 6'); as root ?

Post by SBSP »

How would i run a system command with PHP as the root user and not the PHP/Apache user ?

You can either have code

Code: Select all

system('init 6'); 
or

Code: Select all

exec('init 6'); 
Damina
Registered User
Posts: 42
Joined: 06 Sep 2005, 02:00
Contact:

Re: PHP code - > system('init 6'); as root ?

Post by Damina »

Try using the using the exec command.
It's like the system command and also only takes one parameter.
Your best chance of running anything as anyone other than the webuser is to create a seperate PHP script with your exec command in it.

So your one script would look lke this
<?
exec('init 6');
?>
Then in your other script use the PHP exectuable to run that script, like this:
exec ('/path/to/php /path/to/script');

To find the at to the PHP executable, type which php in command line. /path/to/script referes to the script containing the exec('iit 6') statement.
Post Reply