bobmct Posted October 18, 2011 Share Posted October 18, 2011 In my php web program I'm trying to execute a bash shell script on the web server passing to it some parameters gathered within the program. Ideally I wouldl ike to run this script as another user. However, I get only a return code of "1" and no other error messages that I can see. I tried using system and passthru as well and I'm sure the script is executable by anyone. I've also tried the sticky bit on the target shell script. Can someone/anyone please provide some gotcha pointers about doing this? As can be expected, after playing with this for a week now I'm extremely frustrated and nearly exhausted my resources (except for this forum). Ideas/suggestions please? Thanks Link to comment https://forums.phpfreaks.com/topic/249336-executing-shell-script-using-exec/ Share on other sites More sharing options...
xyph Posted October 18, 2011 Share Posted October 18, 2011 What happens when you run this script: <?php exec( 'whoami', $return, $result ); print_r( $return ); ?> Link to comment https://forums.phpfreaks.com/topic/249336-executing-shell-script-using-exec/#findComment-1280290 Share on other sites More sharing options...
bobmct Posted October 18, 2011 Author Share Posted October 18, 2011 The web server is running as user www-data and the script is owned by podcast:podcast with the permissions of rwsr-xr-x The target script is already in production run by cron and sometimes from the CLI. Hope this helps Link to comment https://forums.phpfreaks.com/topic/249336-executing-shell-script-using-exec/#findComment-1280297 Share on other sites More sharing options...
xyph Posted October 18, 2011 Share Posted October 18, 2011 I'm trying to verify that PHP is properly executing external applications, thus my example. If the output of whoami is as expected, then it's a pathing or permission issue. Have you read the user comments about exec in the manual? There are a lot of 'gotcha's that require a little more knowledge about your setup than you've provided. Link to comment https://forums.phpfreaks.com/topic/249336-executing-shell-script-using-exec/#findComment-1280300 Share on other sites More sharing options...
bobmct Posted October 18, 2011 Author Share Posted October 18, 2011 Thanks - I do believe its a permissions issue. I have read through all the comments under the referenced functions found in us.php.net but I will read them again. Perhaps I've missed something. I will post my result after I have an opportunity to reread those comments. Bob Link to comment https://forums.phpfreaks.com/topic/249336-executing-shell-script-using-exec/#findComment-1280305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.