d.shankar Posted October 3, 2009 Share Posted October 3, 2009 Hi all ! I had this forking script with php running fine. But today i moved to a new host, but the parameter is not getting fetched. The main concept behind the code is EXEC() forking. we have 2 files parent.php and child.php. the parent.php when executed creates a file and registers the time in the file it began and forks a child process and gets exited. the child process now executes and registers its time and then exits. These things work fine but the parameter i send from the parent process is not getting feched to the child process. but the same script is running in other servers. parent.php <?php error_reporting(E_ALL); // place these two lines at the top of ini_set('display_errors', 1); // the script you are debugging //echo exec('whoami'); $book="god"; exec("child.php testing $book > /dev/null 2>&1 &"); if ($fp = fopen("log.txt", "a")) { fwrite($fp, "Parent process finished at ".date("H:i:s", time())."!\n"); fclose($fp); } ?> Child.php <?php error_reporting(E_ALL); // place these two lines at the top of ini_set('display_errors', 1); // the script you are debugging sleep(5); if ($fp = fopen("log.txt", "a")) { fwrite($fp, "Child process $argv[1] $argv[2] finished at ".date("H:i:s", time())."!\n"); fclose($fp); } ?> I am waiting... Thanks Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/ Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 Make sure your log.txt file has 777 Permissions. if log.txt is in a sub folder, the folder need to be 777 aswell. if your getting errors could post the error your recieving? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929831 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 Thanks for replyin ProXy_ I aint getting any errors The expected result is Parent process finished at 7:03:45 Child process testing god finished at 7:03:50 FYI : testing and god are the variables i send from parent.php The result i get now is Parent process finished at 7:03:45 Child process finished at 7:03:50 The variables are not getting printed. Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929846 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 ok, i would try this then.. Parent <?php error_reporting(E_ALL); // place these two lines at the top of ini_set('display_errors', 1); // the script you are debugging //echo exec('whoami'); $book="god"; exec("child.php testing $book > /dev/null 2>&1 &"); $fp = fopen("log.txt", "a"); fwrite($fp, "Parent process finished at ".date("H:i:s", time())."!\n"); fclose($fp); ?> Child <?php error_reporting(E_ALL); // place these two lines at the top of ini_set('display_errors', 1); // the script you are debugging sleep(5); $fp = fopen("log.txt", "a"); fwrite($fp, "Child process $argv[1] $argv[2] finished at ".date("H:i:s", time())."!\n"); fclose($fp); ?> hopefully this helps. Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929851 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 did u just remove the if loop ? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929854 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 I removed the if statement, its not a loop. Basicly your saying if $fp = "blah" then: save information.. But your not previously calling $fp to be anything at all.. therefor its not going to do anything but sit there unless your leaving code out and your calling $fp somewhere down the line to be log.txt Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929858 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 Nope. the same "space" is getting printed. Main process finished at 14:44:24! Child process finished at 14:44:29! Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929862 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 oh, i appologize, i thought it wasn't saving anything at all.. it sounds like in Child.php the variables $argv[1] $argv[2] aren't passing anything through can i see the form source? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929872 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 form source ??? i have posted all the code Proxy. Just the 2 files !! Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929874 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 Actually i was asking where is $argv[1] $argv[2] being called from? if you notice in child.php where $argv[1] $argv[2] it prints the spaces. thats because $argv[1] $argv[2] doesn't equal anything. So i did a little research with $argv and i here is a link i'll send you to that should explain everything you need only thing i can think of is your current host doesn't have register_argc_argv enabled. you can read more about it here: http://www.php.net/manual/en/ini.core.php#ini.register-argc-argv Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929877 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 i checked the phpinfo register_argc_argv is set to ON what's happening really i dont know.. Proxy Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929884 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 ok, as i'm doing research on this Lets try this. child.php <?php $argv=$_SERVER['argv']; error_reporting(E_ALL); // place these two lines at the top of ini_set('display_errors', 1); // the script you are debugging sleep(5); if ($fp = fopen("log.txt", "a")) { fwrite($fp, "Child process $argv finished at ".date("H:i:s", time())."!\n"); fclose($fp); } ?> this is only testing but lets see what that does. Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929887 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 should i run this separately or using parent process ?? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929890 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 that is the child.php. run the script like usual.. we need to see if argv holds anything. by using $_SERVER['argv']; We're basicly debugging but just run the script like you normally do. Also, can i get your php version? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929896 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 proxy, it shows the same result with a space. i think arguments are not getting passed Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929898 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 ok, can i see what the results look like? on the host that the script works on. therefor i can maybe get a little bit more of an understanding. Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929902 Share on other sites More sharing options...
d.shankar Posted October 3, 2009 Author Share Posted October 3, 2009 i think i am worried that the host has blocked argv accees. is that possible ?? Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929904 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 Very possible. and also it seems from research that PHP 4.3+ won't support alot of commands sent through $argv wich is why i asked your php version. and hosts can disable use of argv commands or Command line scripting period. but i won't stop i'll keep up with the research and get your answer Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-929905 Share on other sites More sharing options...
d.shankar Posted October 4, 2009 Author Share Posted October 4, 2009 Thanks a lot proxy , but unfortunately the research goes more weirder.. cause the PHP version is 5.2.8 Link to comment https://forums.phpfreaks.com/topic/176376-new-webhost-behaving-strangely/#findComment-930024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.