Link to home
Start Free TrialLog in
Avatar of eb110k
eb110k

asked on

How do I execute PHP file from Perl?

Hello, I'm a PHP programmer and newbie to Perl and having a problem.
I'm trying to execute PHP file from Perl script as shown below.
I'm sure the path to PHP is correct.
But it doesn't work.
Please someone advise.

Thank you.
#!/usr/local/bin/perl
#!/usr/local/bin/php
 
system('/home/myweb/public_html/test.php');
 
print "Content-type: text/html\n\n";
 
print "Hello";
 
 
 
==================Code of PHP File======================
<?php
 
mail("info@myaddress.com", "Test", "This message sent by Perl");
 
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mjcoyne
mjcoyne

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjcoyne
mjcoyne

On the other hand, I assume you have a reason that you must include some fuctionality in PHP?  Is there a reason why you must call an external PHP script, rather than just doing it all in Perl (or PHP, for that matter)?
Avatar of eb110k

ASKER

Thank you for your advise.
Yes, I have many reasons to include PHP to Perl.
My website build with PHP and need to work with Perl for some module.
There are lot of functions to process after the Perl script executed.
I wish that I could write everything in Perl for this process, but I really don't have time to work with it since I'm still newbie to Perl.

Avatar of eb110k

ASKER

Thank you for your advise.
Try this
#!/usr/local/bin/perl
 
system('php -f /home/myweb/public_html/test.php');
print "Content-type: text/html\n\n";
print "Hello";

Open in new window