html - Executing a .sh file with php -


i have written simple hello world script bash file , saved on desktop.

i want execute file when submit button pressed.

the following script works fine , see hello world on firefox webbrowser:

   <?php       echo shell_exec('sh /home/administrator/desktop/helloworld.sh');      ?> 

however following script not give me result:

<!doctype html>   <html>  <body>  <?php if (isset($_post['submit1'])) {   echo shell_exec('sh /home/administrator/desktop/helloworld.sh');   }   ?>  <input type = "submit" name ="submit1" value = "save parameters">   </body> </html> 

any idea why? don't errors in log file.

you not posting anything, you'll need form, i.e.:

file.php

<html> <body> <?php if (isset($_post['submit1'])) {  echo shell_exec('sh /home/administrator/desktop/helloworld.sh');   }  ?> <form action="file.php" method="post"> <input name= "submit1" type="submit"> </form>  </body> </html> 

also, make sure file /home/administrator/desktop/helloworld.sh executable, i.e.:

chmod +x /home/administrator/desktop/helloworld.sh 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -