I need to learn the command to execute a linux shell command through PHP. The script will be owned by the same user that will also be running the PHP file. It will however be in a different directory. Can anyone give me a code or something on how to do this? Thanks a lot!
As long as PHP Safe Mode isn't enabled, you should be able to execute the script in a number of ways. You could use backticks, or you could use the shell_exec(), exec(), system(), or passthru() functions.
If you'd like examples, there are more than plenty right here:
Ya I used the shell_exec script but it won't let me execute a script to stop a game server. I am trying to execute a script that has inside of it: "killall -9 screen"
This script works fine in ssh but when I run it through php for some reason it won't work... The server process I am trying to kill is owned by the user who is executing the script also. Yet I can execute other scripts that just echo stuff. Do you have any ideas?
Hey. I think I found what the problem might be with executing this script. The server script that starts the game server will execute because I put in a couple cmds
And those output but the cmd in between it is
screen ./hlds_run .......
Does not run. I believe it may be the fact that I need to be connected to a terminal. Since when I tried to run the cmd to via the screen of the server it gave me this error:
Must be connected to a terminal.