Hello!
I'm sure this is a simple question, but I've had a nightmare! 🙂
I have a PHP script, which connects a bot to an IRC Network. This script works great (for statistics and so forth), and I can launch it either by loading it in my brower, in which case it never stops loading - anything "new" is sent live to my brwoser, so that's not ok.
I then SSH'ed to the machine and used "php bot.php" which loaded the script fine, however, if I close my SSH session the bot dies. Likewise, if I do ctrl+c while in the shell, the bot dies also. I tried using (at someone's advice) "./php bot.php &" which returrned that PHP was an unknown file or directory.
How can I do this and leave the bot running? It has code in the php file to allow it to keep connected "set_time_limit(0);", and my host is ok with it, but I just don't know how. Do I have to launch it via another file?
Just to make this a little more difficult too, is there a function I can add to the bot (a command) so it dies?
Commands in the bot are like:
if (substr(strtoupper($con['buffer']['text']), 0, 5) == ".NICK"){
$args = explode(" ", $con['buffer']['text']);
if (count($args) < 3)
cmd_send(prep_text("Syntax: .nick admin_pass new_nick"));
else
{
if ($args[1] == $CONFIG['admin_pass'])
cmd_send("NICK ". $args[2]);
else
cmd_send(prep_text("Invalid password."));
}
}
so another command ".die password" which will terminate the script? Hope that makes sense.
Also, from the SSH prompt, if the bot is loaded and it somewhat becomes unresponsive and we cannot use the command above, is there another way to kill it?
THANKS!