I have a few game servers that that I need to run shell scripts for frequality. I'm trying to figure out how to run these scripts via a webpage on the same server. It's a Ubuntu Dedicated server.
The website files are located via /var/www/...
The .sh files I need to manually run are located in /home/amservers/.../start.sh
.
I've looked at other answers and I still can't figure it out. How do locate the files and store it and then run exec()?
You could just use the shell_exec() function in PHP:
http://php.net/manual/en/function.shell-exec.php
shell_exec('sh script.sh');
And if you want to use the variables ($1, $2 etc. in bash) you could just type:
shell_exec('sh script.sh variable1 variable2');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With