Tuesday, November 16, 2010

Update on the Bot

I successfully got the bot running all on its own. It starts with a web script and you can kill it with a web script. Now there is more that I want to do with this, but this is a start. Now I am going to try to make a android app that can start and stop the script.

Start script:

shell_exec("/usr/bin/php /var/www/bot.php & ");
echo "Bot Started Successfully";




Stop Script: (some code is borrowed from the php manual thanks to Ashraf M Kaabi)

function kill($PID){
if(is_running($PID)){
exec("kill -KILL$PID");
return true;
}else return false;
}
function is_running($PID){
exec("ps $PID", $ProcessState);
return(count($ProcessState) >= 2);
}

$output = shell_exec("ps | grep php | awk '{print $1}'");


if ($output != null) {
kill($output);
echo "Killed process id:/" $output /"";
} else {
echo "Output Null";
}



No comments:

Post a Comment