Reputation: 2845
I have a small php script that looks like this :
<?php
$argument1 = $argv[1];
echo "passed Value:".$argument1;
//do something with passed value
//echo processed value
?>
I want to run it multiple times using cmd.
This is how I run it currently :
c:\php\php.exe MyScript.php 1
I want to run the above cmd line multiple times for different values ranging from 1 to 100.
Could anyone tell me how I can run it multiple times for different values passed to it?
I want to be able read the output of each php call and copy it
Upvotes: 2
Views: 944
Reputation: 691
For doing it in the shell itself:
FOR /L %parameter IN (start,step,end) DO command
For example:
FOR /L %x IN (1,1,100) DO c:\php\php.exe MyScript.php %x
For doing it in a .bat file:
FOR /L %%parameter IN (start,step,end) DO command
For example:
FOR /L %%x IN (1,1,100) DO c:\php\php.exe MyScript.php %%x
However, I don't know if this will output the outcome.
Source: SS64
Edit: changed %%x to %x and replaced 1 by %x -- thanks both of you :D
Upvotes: 2
Reputation: 56180
(FOR /L %x in (1,1,100) DO c:\php\php.exe MyScript.php %x)>output.txt 2>&1
>output.txt
redirects STDOUT to a file. 2>&1
redirects STDERR to the same place.
(Note: this is a command line syntax. To use it in a batchfile, use %%x
instead of %x
)
Upvotes: 4