LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Q: Run a sh script in httpdoc (https://www.linuxquestions.org/questions/programming-9/q-run-a-sh-script-in-httpdoc-617290/)

bassamh 01-29-2008 08:00 PM

Q: Run a sh script in httpdoc
 
Hello, first I thank anyone who try to get me up of this Q.



I have a script to start/stop a prog ( /usr/bin/Pro.d1) this script locate in /var/script1.sh.

Code:

#!/bin/sh
PRONAME="MyPro"

start_pro ()
{
/usr/bin/Pro.d1 &
sleep 2
}
# This method stops MyPro
stop_pro ()
{
killall Pro.d1
}
case "$1" in
start)
echo "[SCRIPT] $1: $PRONAME"
start_pro
;;
stop)
echo "[SCRIPT] $1: $PRONAME"
stop_pro
;;
restart)
echo "Restaring $PRONAME"
stop_pro
start_pro
;;
*)
"$0" stop
exit 1
;;
esac
exit 0


what I want is a PHP file (eg: index.php) that will execute the /var/script1.sh

I try one :

Code:

<?php
$return = exec("/var/script1.sh");
echo "Executing Status: $return";
?>

but Unfortunately the file wouldn't run or maybe the exec() was disabled.

Any ideas

Thanks

Tinkster 01-30-2008 02:26 PM

Hi,

And welcome to LQ!

The first suggestion would be to enable debug output for PHP to
find out what happens?


Cheers,
Tink

P.S.: Moving this thread over to programming where it is more suitable....


All times are GMT -5. The time now is 08:01 PM.