Running a .sh file via PHP
I'm trying to run a .sh file from a PHP script. It needs to run in a screen as well as it runs a java file which needs to keep running until it's killed.
The following code works although if I try putting the path to the .sh file in then it doesn't appear to run. Code:
$output = shell_exec('ps aux | grep http'); EDIT: I've got it working with <?php shell_exec('sh /path/to/file.sh >/dev/null &' ); ?> which I had tried before... and then I remembered that the specific .sh I was trying didn't work correctly, oh well only a few hours of my life lost! |
To rule out the simple things, have you made sure that your sh file is correctly chmod'd to execute? Also, you might have to run a direct command to run the sh file, like so:
Code:
sh file.sh Josh Edit - I didn't see your edit.... my fault for not reading too thoroughly :D As a note though, you could also use "bash" instead of sh, if the file contains strictly bash code, or zsh, etc... |
All times are GMT -5. The time now is 04:49 PM. |