MyBB Community Forums

Full Version: Executing shell script in PHP?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am very new to this as this is my first shell script I've written (all it does is automatically install new MyBB forums on subdomains and setups up the database accordingly). I'm looking for an alternative to executing this other than command line. Thanks.
I'm not sure if this is correct, but you may want to look at the exec() function.
I tried that but I don't know what I'm doing wrong. Sad

<?php
exec('/my/script/directory/script.sh');
?>
I really don't know - do you have to supply the script as an argument to bash?
For example, maybe:
exec('/bin/bash /my/script/directory/script.sh');

...I really don't know, sorry.
you can execute it using yum or sudo, can you not?
Actually I figured it out. I was having problems with permissions since anything executed via PHP is run by the apache user (I should have known that) so now I'm trying to rethink this idea. I guess I could do sudo but I like keeping the script run in a jailed shell account since I'm still very new to this and have to many production websites to worry about at the moment. Big Grin For now I'll stick to executing via command line and when I get more admin or a higher demand for MyBB forums I'll worry about a web interface.
Thanks, that would work perfectly for me but after reading the warning I will hold off on that option since the risk appears to great for my unexperienced self. Big Grin
The warning? o.o
The "Before we begin." section...
Pages: 1 2