PHP on the command line and batch files

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
kinnon
Forum Newbie
Posts: 4
Joined: Wed Jan 24, 2007 9:23 am

PHP on the command line and batch files

Post by kinnon »

Hi. I have a batch file which looks like

php a
php b
php c

php refers to a batch file in the php directory that looks like this:

ECHO OFF
IF NOT EXIST %1.php goto usage
php-cgi.exe -q %1.php
goto end
:usage
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ USAGE ³
echo ³Type "php.bat" (without quotes)³
echo ³ followed by the name of a ³
echo ³valid php file without the .php³
echo ³extension. ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
:end

a b and c are .php files, but only a is executed.

Regardless of what the php code is, each file should be run, one after the other, but they dont.

Does anyone know whats going on?

This is so I can automate routine tasks on a win2k server.

Thanks for your time,
kinnon.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Maybe php.exe is interfering?
kinnon
Forum Newbie
Posts: 4
Joined: Wed Jan 24, 2007 9:23 am

Post by kinnon »

feyd wrote:Maybe php.exe is interfering?

Windows tends to go for bat files first if no extension is defined, however, worth a try.
Modified the batch file to contain

php.bat a
php.bat b
php.bat c

so there would be no uncertainty. still the same result im afraid.

Thanks for the suggestion ... or have I misunderstood you?

kinnon
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Hang on a second, you have two batch files?

If you run another batch file without a special command, the current batch file terminates. If memory serves it's the "call" command, as-in "call php.bat a" or something similar.
kinnon
Forum Newbie
Posts: 4
Joined: Wed Jan 24, 2007 9:23 am

Post by kinnon »

feyd wrote:Hang on a second, you have two batch files?

If you run another batch file without a special command, the current batch file terminates. If memory serves it's the "call" command, as-in "call php.bat a" or something similar.
AHA. your right!! its sorted. You have just saved me a lot of hassle.
Without the call command, the execution does not get passed back to the origional batch file, so the other lines dont get run.

Thank you.
Post Reply