aravin Posted March 14, 2010 Share Posted March 14, 2010 i have a problem run following script <?php $output=shell_exec("echo 'password' | sudo -S <command>"). echo $output; ?> i already adding "www-data ALL=NOPASSWD: ALL” in my etc/sudoers folder but it still not working. i really appreciate if somebody can help me and give step to solve it. Quote Link to comment Share on other sites More sharing options...
5kyy8lu3 Posted March 14, 2010 Share Posted March 14, 2010 i have a problem run following script <?php $output=shell_exec("echo 'password' | sudo -S <command>"). echo $output; ?> i already adding "www-data ALL=NOPASSWD: ALL” in my etc/sudoers folder but it still not working. i really appreciate if somebody can help me and give step to solve it. it's not safe to remove ALL restrictions, so you should instead remove restrictions from the functions you're calling. for example, if you wanted to remove root prerequisite for fdisk, you'd type 'sudo visudo' in terminal and add this line: www-data ALL=(root) NOPASSWD: /sbin/fdisk then you can do a shell_exec("sudo fdisk"); and get results. now i haven't tested it but i add the entire command, including arguments in the sudoers (the file you edit when you do a sudo visudo) might unlock just the command with that specific set of arguments, but i'm not sure of this, i didn't feel like testing it. make sure you only edit sudoers with sudo visudo from terminal, if you do a gksudo gedit sudoers, and you edit it incorrectly and save it, you're going to be in ALOT of trouble lol good luck Quote Link to comment Share on other sites More sharing options...
aravin Posted March 14, 2010 Author Share Posted March 14, 2010 I get some out put by tring this coding. But my password is not correct even i have try many possible password. code: <?php $output=shell_exec("echo 'password' | sudo -S <command> 2>&1" ); echo $output; ?> error: [sudo] password for nobody: Sorry, try again. [sudo] password for nobody: sudo: 1 incorrect password attempt any idea to solve it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.