Page 1 of 1

Execute php file from command line

Posted: Thu May 31, 2007 8:24 pm
by GeXus
I have a script, basically a spider.. that I would like to run on the server.. how would I execute it from the command line?

Thanks!

Posted: Thu May 31, 2007 8:26 pm
by superdezign
Find php.exe. I believe you use the -r argument to run, but I could be mistaken. I don't run much PHP from the command prompt.

Edit: I'm sorry, I think it's -a.

Posted: Fri Jun 01, 2007 3:03 am
by WaldoMonster
Use php from the cli directory, the other php is for fast-cgi.

Usage with php tags in the script:

Code: Select all

php -f "pathtoscript/test.php"
Usage without php tags in the script:

Code: Select all

php -r "pathtoscript/test.php"
For all parameters run:

Code: Select all

php --help

Posted: Fri Jun 01, 2007 7:27 am
by feyd
-r is used for code in the command line, not an external file.