the_oliver Posted January 1, 2007 Share Posted January 1, 2007 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 More sharing options...
the_oliver Posted January 1, 2007 Author Share Posted January 1, 2007 bump* Link to comment https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151015 Share on other sites More sharing options...
cunoodle2 Posted January 1, 2007 Share Posted January 1, 2007 Please be more specific. In fact lets aim for 1 specific function that you want to do and then go on from there. Link to comment https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151029 Share on other sites More sharing options...
the_oliver Posted January 1, 2007 Author Share Posted January 1, 2007 Sure, one example would be creating a local user on the linux server, using a variable (eg the name) passed to it from a php scrit. I want this to happen when a web user submits a form or something. - Thanks Link to comment https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151033 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Look at [url=http://php.net/shell_exec]shell_exec[/url] and its realted functions. Link to comment https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151074 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 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 https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151203 Share on other sites More sharing options...
the_oliver Posted January 2, 2007 Author Share Posted January 2, 2007 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 https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151326 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 [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 https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151330 Share on other sites More sharing options...
the_oliver Posted January 2, 2007 Author Share Posted January 2, 2007 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 https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151337 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 [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 https://forums.phpfreaks.com/topic/32462-having-php-run-a-script/#findComment-151350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.