ashly Posted February 27, 2007 Share Posted February 27, 2007 Hi, I have to execute multiple PHP scripts conditionally from a single PHP script, that is executed by a cron. Actually i wanted to do is instead of using require or include for each page, execute each page directly from the script like a function call. is there any methods in PHP? if anybody have any idea, pls reply.. Thanks Ashly Quote Link to comment Share on other sites More sharing options...
fert Posted February 27, 2007 Share Posted February 27, 2007 http://us2.php.net/manual/en/function.system.php Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 ok..it is nice.. thanks.. How do i use passthru() function to execute a php script? Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 What if you just used addrees varibles to tell the php what to execute.. http://address.com/execute.php?prop1=1&prop2=1 The using requests: $prop1 = $_REQUEST('prop1') ; $prop2 = $_REQUEST('prop2') ; if ($prop1 == 1) { YOUR ECECUTE SCRIPT HERE ; } if ($prop2 == 1) { YOUR ECECUTE SCRIPT HERE ; } Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 what i am looking for is to get an example of usage of passthru() function to execute a php script from another php script.. Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 Its pretty stright forward like exec and system $command1 = "/bin/users/htdocs/test1.php" ; $command2 = "/bin/users/htdocs/test2.php" ; passthru($command1, $command2); Make sure you use the whole path or it will return error 127. Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 My code is like this: passthru("/var/www/myhost/test.php"); but it doesn't workout.. any idea? Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 Try it without the quotes. passthru(/var/www/myhost/test.php); or user single quotes. passthru('/var/www/myhost/test.php'); Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 First one makes Parse error like: Parse error: syntax error, unexpected '/', expecting ')' in /var/www/myhost/execfunctioncaller.php on line 17 and the second one has no output... Quote Link to comment Share on other sites More sharing options...
play_ Posted February 27, 2007 Share Posted February 27, 2007 If the second one isn't returning, does the script tell it to return a value? Quote Link to comment Share on other sites More sharing options...
Jenk Posted February 27, 2007 Share Posted February 27, 2007 You could always try reading the manual .. http://us2.php.net/manual/en/function.passthru.php Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 What is line 17 of the file being passed thru? Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 i read the manual completely..but no information there. As the code there is: <? print "reached here"; ?> The script test.php should have to print "reached here". Is it? Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 Line number 17 is passthru(/var/www/myhost/test.php); Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 No the error was coming from line 17 of execfunctioncaller.php... If you open test.php with that print statement it will show you nothing. Thats why you see nothing. Quote Link to comment Share on other sites More sharing options...
ashly Posted February 27, 2007 Author Share Posted February 27, 2007 now i changed the code in test.php as mail('mymail@host.com', 'My Subject', 'Test message'); but i don't get the email.. the server is configured for mail fuction also.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.