Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oddities of exec

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
So if I type the following into a command window in XP
Code:
"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv" "Some Directory With Spaces\\somefile.vcproj"

It compiles fine.

If I run the following PHP code
Code:
$compiler = '"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv"';

exec($compiler.' directorywithoutspaces\\somefile.vcproj,$output,$error_code);

It runs fine... but if I run
Code:
$compiler = '"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv"';
$arg = '"directory with spaces\\somefile.vcproj"';

exec($compiler.' '.$arg);

It spits back
Code:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Error code is obviouslly 1 for that.

Anyone know what could be causing this?
 
Have you tried swapping your backslashes with forwardslashes? I infer that you're running PHP on Win32 and know that Win32 uses backslashes for directory separators, but PHP gets weird with backslashes sometimes.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
a vague answer - i'm afraid: i remember seeing something about this in the last couple of weeks. the advice from the poster in question was to you the old dos 8.3 filename structure.
 
Well my workaround is to use the quotes on the path to the compiler (since that's a registry value and I can't use the 8.3), and the 8.3 on the second argument, which sucks, because it's not 100% predictable in this case.

And yeah, I tried all the forward/backslashes... escape characters, etc. It just seems to be something about having double quotes around two different arguments that throws exec for a loop.

I'm running a slightly old version (4.3.8) so perhaps I'll upgrade and file a bug report if I can't figure it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top