Re: Problems with shell_exec() running .bat with For /F
| From: | Fred | Date: | Thu, 30 Jun 2005 03:24:34 +0000 |
| Subject: | Re: Problems with shell_exec() running .bat with For /F | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-26163@lists.php.net to get a copy of this message | ||
So here is the source of the problem, but not the cause.
From the XP command line etc. the dir returns a file line of
04/02/2005 02:09 AM 19405754 filename.ext
but when invoked from shell_exec() it returns
04/02/2005 02:09 19405754 filename.ext
which means that for some reason the PHP evoked shell isnt picking up the
custom regional settings on the machine.
Its easy enough to work around, but is this a bug or have I missed some
finer point about regional settings?
""Fred"" <bloggsfred00@hotmail.com> wrote in message
news:9C.6A.42553.94943C24@pb1.pair.com...
> 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?