Problems with shell_exec() running .bat with For /F

From: Date: Thu, 30 Jun 2005 01:22:10 +0000
Subject: Problems with shell_exec() running .bat with For /F
Groups: php.windows 
Request: Send a blank email to php-windows+get-26162@lists.php.net to get a copy of this message
PHP5 - Apache2 - XPSP2 I have an XP batch file incorporating a For /F command which behaves strangely if run from a shell_exec() or system(). Specifically, if the batch is run from a command prompt or from the scheduler, it works as expected, but if I run the same batch from shell_exec() the For /F misbehaves interpreting token fields. Paraphrasing, "For /F "tokens=1-4" %%a in ('dir /-c c:\somedir') do if /I %%d==somevalue dosomething" always returns the fourth space delimited field for %d when run fom an XP cammand prompt or scheduler, but sometimes returns the third space delimited field when run from shell_exec(). It always returns the wrong field from the same dir output lines. The only coincidence seems to be that it returns the wrong field when there are lots of consecutive spaces preceeding the field. Got me beat. Anyone had similar issues? Please?

« previous php.windows (#26162) next »