03.07.2014, 12:55
Ich benötige einmal eure Hilfe. Ich suche Jemanden der In PHP Programmieren kann. Und zwar geht es um Folgendes. Ich benötige ein PHP Script das Server seitig läuft. Es soll per Shell_exec einen Command von einem Linux Server Ausführen. Es handelt sich auf dem Linux Server um einen Shoutcast Transcoder der Gestopt/Gestartet werden soll per Klick eines Buttons. Hier einmal das was ich probiert habe umzusetzen aber nicht gelungen ist. Mir würde es auch reichen wen mir wer Hilft das Script richtig umzusetzen.
Script
Script
PHP-Code:
#!/bin/bash
#!/usr/bin/php -q
# To start the script automatically at bootup type the following command
# update-rc.d sc_trans defaults 99
USER=shoutcast
MYDIR=`/home/shoutcast/sc_trans_9000 $0`/
case $1 in
start)
#display to user that what is being started
echo “Starting sc_trans_linux”
#start the process and record record it’s pid
cd $MYDIR ; screen -AmdS stream ./sc_trans_linux;
sleep 2
ps -A | grep sc_trans_linux | cut -c 0-6 > /var/run/sctrans.pid
#output failure or success
#info on how to interact with the torrent
#echo “To interact with the torrent client”
#echo “screen -r torrent”
if [[ $? -eq 0 ]]; then
echo “The process started successfully”
else
echo “The process failed to start”
fi
;;
stop)
#First we want to kill the original servers, so we don't get errors.
echo "Killing old shoutcast streams."
for oldpid in `ps -A | grep sc_trans_linux | cut -c 0-6`; do
kill -9 $oldpid
done
rm -f $pid
;;
*)
# show the options
echo “Usage: {start|stop}”
exit 1
;;
esac
exit 0
Start.php
PHP-Code:
<?
$out = array();
$shell = shell_exec("cd /home/shoutcast/sc_trans_9000/; ./script start");
print_r($out);
?>
Stop.php
PHP-Code:
<?
$out = array();
$shell = shell_exec("cd /home/shoutcast/sc_trans_9000/; ./script stop");
print_r($out);
?>