File Path Rules for PHP exec()

What are the 'rules' for specifying file paths for PHP's exec() function?  I am running PHP under Apache 2 in Windows XP.  I gather that the path separators need to be forward slashes.  I have not worked out what to do with spaces, though.  If there are any spaces in my file paths execution fails.  How can I escape spaces?  Also, are there any other Windows allowable characters that are likely to cause problems?

Mike

shachoAsked:
Who is Participating?
 
Michael701Connect With a Mentor Commented:
you could use quotes around the file names in the exec

ie xp allows

copy "c:/temp/my file.txt" "d:/whatever.txt"

0
 
shachoAuthor Commented:
I tried that earlier, but it also fails for the same reason.  I get an error message saying the file cannot be executed and it displays the path all the way up to the first space.
0
 
Michael701Commented:
did the path that was displayed have a quote before the file name?

can you post an example?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
shachoAuthor Commented:
Problem solved.  The quotes need to be inside the text that is sent to the shell (I should have guessed that right off) so:

exec('C:/my folder/file.vbs')   //does NOT work (single quotes)
exec("C:/my folder/file.vbs")   //does NOT work (double quotes)
exec('"C:/my folder/file.vbs"')   //DOES work (double quotes INSIDE single quotes)

...which is probably what you meant by the first post, yes?

0
 
Michael701Connect With a Mentor Commented:
yep, that's it
0
 
shachoAuthor Commented:
Great.  Thanks a lot for your help!

Mike

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.