Re: Command Line PHP Advice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
Hi,
 you can do this by using unix command 'for'. Please apply the
command written below & reply me your experiment result.

for filename in `ls *.txt`;do ./edit.php $filename var1 var2;done


--Nirmalya
 

Angelo Christou <christou44@xxxxxxxxx> wrote: Hello List
I would like some advice from PHP users regarding PHP and the command line. I have a PHP script that does a whole bunch of stuff to a file on my intranet.

./edit.php filename var1 var2

Everything works fine but I need to run it on a list of files  - 

./edit.php invoice00212.txt var1 var2
./edit.php invoice00213.txt var1 var2
./edit.php invoice00214.txt var1 var2

I have a list of several thousand files that will change every month. The list has the filenames and variables, like this so I am half way there I think -

invoice00212.txt var1 var2
invoice00213.txt var1 var2
invoice00214.txt var1 var2

My question is how should I incorporate this with my PHP script?

I read that it's better to split scripts up into small reusable parts so my plan is to keep the logic out of the edit.php script and simply pass the variables to it using another script. Am I on the right path doing this?

I am only a beginner with PHP so I admit I don?t really know what I?m doing, that is why I am asking for pointers from the PHP Mail List :)

Below is my model, however I am unsure how to achieve this or even if it's the best way to do it?

open filelist.txt
for each line create $filename $var1 $var2
then run
./edit.php $filename $var1 $var2
loop back to the next line
end

Many thanks in advance,
Ang.
 

  
---------------------------------
Do you Yahoo!?
 With a free 1 GB, there's more in store with Yahoo! Mail.


				
---------------------------------
Bring words and photos together (easily) with
 PhotoMail  - it's free and works with your Yahoo! Mail.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux