Kooleo956 Posted July 6, 2008 Share Posted July 6, 2008 I have been to several forums about this problem and most of them say to use cron jobs, but I find it annoying to go through cron jobs every time I want this script to start up. Each file has an infinite while loop, and I want the server to execute each file. I do not want to have to force a person to leave the file open to keep the script running and I do not want to go through cron jobs. I just want a PHP page where it creates a ghost user that is run by the server and that ghost user executes these PHP files. I tried something like this: <?php system("php /home/user/bot/bot.php"); system("php /home/user/bot/message.php"); sleep(10); system("php /home/user/bot/logs.php"); ?> , but it did not work. Could someone please help me, and thank you for reading this if you cannot. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/ Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 Try placing the execution into the background. system("php /home/user/bot/bot.php &"); Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583070 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 Yeah, that did not work either. It did not work at all, it did not even start up the php file, and it did not give me an error. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583087 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 I'm not sure there is anything else you could try, this really isn't http's forte. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583092 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 Well, can I start with the basics, how do I get it to execute a php file? Becuase no matter what I try, it does not execute it. Do you think it may be that it is not available to the public? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583095 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 Most likely php isn't in your path. You will need to use the full path to the executable. eg; system("/usr/bin/php /home/user/bot/bot.php &"); Also, make sure error reporting and display errors are on so we can see what is going on. <?php error_reporting(E_ALL) ; ini_set('display_errors','1'); ?> Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583099 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 Yeah, how long does that script run? because my cpanel has been going very slow since I tried to execute that. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583111 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 How should I know? Its your script. If it has an infinant loop as your suggested it will run forever. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583114 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 No, it never got to run the infinite loop, otherwise It would of exited out immediately because I set it to exit out immediately. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583115 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 No, it never got to run the infinite loop, otherwise It would of exited out immediately because I set it to exit out immediately. Well, thats no infinant loop then is it? Either way, I would have no idea about how long your script runs. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583117 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 It never made it to the script, I am pretty sure. The site is still up, and the script never made the cpanel run slow. Plus the script delays by a quarter of a second every loop. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583121 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 Did you turn error reporting and display errors on? Did you see any error? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583127 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 I turned error reporting on and no errors have been returned Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583133 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 Try this... <?php error_reporting(E_ALL) ; ini_set('display_errors','1'); system("/usr/bin/php /home/user/bot/bot.php &",$return); if ($return ==0) { echo "script executed successfully"; } else { echo "execution failed"; } ?> Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583136 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 it says "script executed successfully", but the script did not seem to execute. I changed the script to execute this: <?php $lfp = fopen('bot.txt', 'w'); fputs($lfp, "this is data.\n"); fclose($lfp); ?> but when I did that, no bot.txt was formed. Oh, and I found out why the cpanel was running slow. Apparently since the path php did not exist, it just made the server lag REALLY bad. Is there a way to prevent that from happening? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583147 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 but the script did not seem to execute. What makes you think that? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583149 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 Apparently since the path php did not exist, it just made the server lag REALLY bad. Is there a way to prevent that from happening? Of course if the path to php doesn't exist your script won't execute. You might want to detail exactly what it is your trying to accomplish, this really isn't going anywhere. Do you have access to the php cli? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583153 Share on other sites More sharing options...
Kooleo956 Posted July 6, 2008 Author Share Posted July 6, 2008 actually the link to the php is /php it was rather basic. I am trying to start a php file having the server run the php file rather than the client. if i just do system("/php /home/user/bot/bot.php",$return); it returns as failed, but if I do system("/php /home/user/bot/bot.php &",$return); it returns successful Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583159 Share on other sites More sharing options...
trq Posted July 6, 2008 Share Posted July 6, 2008 /php seems an odd place to have php installed or is that just a link to the executable. Do you have shell access? if so, what is the output of the following? which php Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583161 Share on other sites More sharing options...
Kooleo956 Posted July 7, 2008 Author Share Posted July 7, 2008 /usr/bin/php but when i tried that, it made the server lag like before. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583177 Share on other sites More sharing options...
trq Posted July 7, 2008 Share Posted July 7, 2008 /usr/bin/php but when i tried that, it made the server lag like before. Can we see your bot.php script? Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583399 Share on other sites More sharing options...
Kooleo956 Posted July 7, 2008 Author Share Posted July 7, 2008 As of right now this is the script I was trying to run <?php $lfp = fopen('bot.txt', 'w'); fputs($lfp, "this is data.\n"); fclose($lfp); ?> once I get that to run I will try my actual script. Link to comment https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/#findComment-583436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.