0

I want to run a executable file on my server when a user clicks a button on webpage. I am able to run the executable using exec command but the program runs under 'nobody' even if I followed the instructions in post : How to run from PHP a bash script under root user answer by : Riateche

But still the execuable file runs under 'nobody'

My executable program is kept in directory

/opt/lampp/htdocs/project

My php code

<?
$variable = 10;
$site_dir = 'project';
echo "<img src ='".exec('/opt/lampp/htdocs/' . $site_dir .'/myProgram '.' '.$_GET['value1'] .' '. $variable )."'>";
?>
Community
  • 1
  • 1
Devendra
  • 89
  • 2
  • 11

2 Answers2

0

You are not using the sudo keyword before your command:

echo "<img src ='".exec('/opt/lampp/htdocs/' . $site_dir .'/myProgram '.' '.$_GET['value1'] .' '. $variable )."'>";

Should be:

echo "<img src ='".exec('sudo /opt/lampp/htdocs/' . $site_dir .'/myProgram '.' '.$_GET['value1'] .' '. $variable )."'>";
Lock
  • 5,422
  • 14
  • 66
  • 113
0

i think you need to add a rule to sudo users/rules file to allow your command to run without entering your or root password. This link might tell you how to do that. here https://help.ubuntu.com/community/RootSudo

Tyson
  • 1