Page 1 of 1

PHP on the command line and batch files

Posted: Wed Jan 24, 2007 9:45 am
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.

Posted: Wed Jan 24, 2007 9:48 am
by feyd
Maybe php.exe is interfering?

Posted: Wed Jan 24, 2007 10:00 am
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

Posted: Wed Jan 24, 2007 10:11 am
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.

Posted: Wed Jan 24, 2007 10:31 am
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.