Jump to content

having php run a script...


the_oliver

Recommended Posts

Hello.

Not sure if i am asking this in the wright place or not however . . . . .
Im trying to find a way to have a list of tasks done on a linux server, triggered by a PHP script and with values passed to it.  These are things like adding a new user on the service, creating files and permisions etc.  These there for need to be run as root.  How could i go about this?  Slightly lost for ideas!

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/
Share on other sites

Yup, can pass items in on the command line as well. Beware of security risks though when using this strategy. Don't forget to validate the input and escape it before you ever run a shell command.

Also, SELinux can cause certain things to act funky if you try to do anything beyond very basic command execution.
Thanks, i look at shell_exec but i cant work out how to make it a two way thing?  For example if i send it a comand that sends me on option back, how do i get it to hold its state?

dbo: Security risks were my main consern!  Some of the things i run have to be run as root, and i clearly dont want to put the root password anywhere near my web server if i can avoid it!  But im not entirly sure what you meen by this:

[quote]validate the input and escape[/quote]

- Thanks
[quote]if i send it a comand that sends me on option back, how do i get it to hold its state?[/quote]

Do you meen if the command prompts you? This sort of thing really can't be handled even in a native shell.

The only Linux commands that should prompt you for anything are login. What exactly are you trying to do?
One of them would have to be log-in in this case to gain the correct privilages.....
One way i was thinking of doing it would be to have a php script submit results to a database, and then another running under roots cron jobs, getting the infomation back, and dealing with it.  Does this sound like it would work?
[quote]Does this sound like it would work?[/quote]

Sorry, but your description doesn't make allot of sense. Running under roots cron jobs? sorry, youve lost me.

Look into using sudo to run any root commands. You can setup sudo in such a way that it doesnt prompt for a password. Ide be real carefull running this though a website though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.