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
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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.