Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing php files

Status
Not open for further replies.

ckennerdale

Programmer
Dec 23, 2000
158
GB
I want to execute 3 php files via cron,but my isp wont let me,but will let me execute a perl script.

I know no perl.

Can I get perl to execute my php files once it has been execute itself?

Any ideas?

Thanks in advance Caspar Kennerdale
Senior Media Developer
 
If your PHP scripts can be executed from the command line, then I don't seen any reason why they couldn't be executed from Perl, and the Perl script executed from cron.

You need to read up on Perl's ways of executing external commands - the 3 ways I'm familiar with are

* system
* backticks
* exec

I've never used exec, so much hunch is that either the "system" Perl function, or backticks(if you want to capture the STDOUT from the command you run) will accomplish what you want.

Questions:
1) Did your ISP say that you could run a Perl script from
cron?
2) Can you run your PHP scripts from the command prompt?
3) What platform are you running on? Hardy Merrill
Mission Critical Linux, Inc.
 
From what I recall, you can build PHP in one of two ways - either it can be built into the webserver(we built it into Apache) in which case I believe the PHP scripts can only be invoked from a browser, or it can be built as a standalone interpreter(this may not be the right term). For you to be able to execute PHP scripts from the command line, or from a Perl script, I think you'll need to have PHP built as a standalone interpreter.

Once PHP is built as a standalone interpreter, on Linux you should be able to do "which php", and the which command will tell you where the PHP executable exists in your PATH. Once you know the location of the PHP executable(interpreter), you then put that in the #! line at the top of every PHP script, like

#!/path/to/php

I recently found this article that describes "Using PHP As A Shell Scripting Language":


Once you've got everything working so that you can execute PHP scripts from the command line, in Perl you'll need to use either "system" or backticks to execute your PHP scripts from within Perl.

HTH. Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top