How can I run php scripts from a shell script?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Newbie about this stuff.

I want to run some php scripts from a shell script(bash?)

the php script i want to run is this:

and it's path is this:

1. How would I creat the shell script?
2. How would I execute it?

I have already tried ot figure it out with no success.

I have php 4.2.2


Re: How can I run php scripts from a shell script? spilled the following:

Quoted text here. Click to load it

PHP can be compiled as a standalone binary or as a module for various
webservers. The former can also be used in conjunction with a webserver.
Life's a lot simpler if you have the standalone binary. I use SuSE mostly -
it's mod_php rpm includes both the module and standalone interpreter. If
you have got it on your machine it'll probably be called 'php' and is
likely to be in /usr/bin or /usr/local/bin. First thing to try would be
`which php` - then try looking in the directories for something named *php*

Then it's just a matter of running the interpreter with the script as the
first argument. e.g.

php /home/virtual/

although you may not want extraneous html in your output so....

php -q test.php

Just in case you can't find it, and can't install your own, you can fetch a
web page from the comand line using a variety of tools - most boxes will
have wget and/or curl.



Re: How can I run php scripts from a shell script?

you can also set the script up like a normal shell script in the form

-- start file --
#!/usr/local/bin/php -q

/* php code here */

--  end file --

the path to php can be take the form of

/usr/bin/env php
/usr/bin/which php

they should all work out fine.

Good luck!

Site Timeline