|
Something to be aware of, which may make everyone rethink
the use of spaces in paths, at least on the Windows
platform.
If you are in a PHP script and wish to run a program whose
path contains spaces AND the program has a parameter which contains spaces, then
the format would be something like ...
<?php
exec('"C:\\Some Program\\In A\\Folder With\\Spaces In\\The
Path\\program.exe" -use "C:\\Some Folder\\Containing A\\File With\\Spaces
In"\\The Path.txt"');
?>
The problem with this is that PHP uses CMD.EXE to run the
above command and CMD.EXE has a bug where will only accept ""'s for either the
program OR the parameter and not both.
You can see this by trying this at the normal windows
Command Prompt...
C:/> cmd /c "C:\Windows\System32\Notepad.exe"
"c:\windows\system32\autoexec.nt"
The error I get is ...
The filename, directory name, or volume label syntax is
incorrect.
If I try ...
C:/> cmd /c
C:\Windows\System32\Notepad.exe
c:\windows\system32\autoexec.nt
Then I get Notepad loaded with autoexec.nt in
it.
As did ...
C:/> cmd /c
C:\Windows\System32\Notepad.exe
"c:\windows\system32\autoexec.nt"
and
C:/> cmd /c "C:\Windows\System32\Notepad.exe"
c:\windows\system32\autoexec.nt
You will notice that neither of the paths contain spaces.
Space are not the bug, the "" are.
So.
Using "" around path names will work as long as ONLY the
program OR the parameter uses it.
Which may be an issue for trying to fix this in the doc
building scripts.
I'm looking for a way of getting the short name of a file
and then to add this to PHP as a windows specific function. I've no idea what
sort of use this would have on a non windows environment, but being able to use
short paths from the known long path could be useful for me at least and
probably scripts where users are not au-fait with long and short
names.
Richard "Sometimes spanner thrower"
Quadling.
|
