LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   running a php script from command line (https://www.linuxquestions.org/questions/linux-newbie-8/running-a-php-script-from-command-line-675526/)

leicaphotos 10-10-2008 01:15 PM

running a php script from command line
 
I've got well over a million flat files and have written a php script that scrapes the necessary content and drops to a mysql database -- I ran it once on a sub section of the files from a localhost browser and it timed out after about 50,000 records...

The script is simple, it reads the file, displays the data it's scraping and inserts it into the database...

I'm running a pretty stock install of latest version of pcbsd and was wondering would it be possible to run this script from the path of /usr/local/www/apache22/data/Sect1 from the command line -- what would be my syntax for this... do I need to be in the directory or elsewhere...


thanks...

CRC123 10-10-2008 01:24 PM

running it through the 'php' or 'php5' command should do it. Here are a few ways that might work given your file was 'script.php':
Code:

php script.php
php -f script.php
cat script.php | php
php < script.php

At least one of those should work, if not, try appending a 5 to the command: 'php5'


All times are GMT -5. The time now is 10:35 AM.