<br><br><div><span class="gmail_quote">On 9/25/07, <b class="gmail_sendername">David Champion</b> <<a href="mailto:dchampion@visionary.com">dchampion@visionary.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Back in the good old days when I was writing Windows desktop apps... I<br>used to always get around this by putting quotes around the path names.<br>This worked, IIRC in Visual Basic and Visual FoxPro.</blockquote><div><br>
<br>Yeah, I tried putting double quotes around it (actually, escaped double quotes so sprintf() didn't have a problem with it). But system() seemed to strip out "some" of the double quotes, not all. I had double quotes around the path to the batch file, and an argument to the batch file. It appeared to remove the first double quote of the batch file, and the last double quote of the argument. I still have to put double quotes in the argument to putenv(), but it does work. If I put into system() what I put into putenv(), it doesn't. So my code went from:
<br><br>sprintf(cmd_line, "\"%s%s\" \"%s\" %s", directory_to_batch_file, name_of_batch_file, arg_to_batch_file1, arg_to_batch_file2);<br>why = system(cmd_line);<br><br>to<br>sprintf(cmd_line, "DEST_DIR=\"%s\"", directory_to_batch_file);
<br>putenv(cmd_line);<br>sprintf(cmd_line, "%%DEST_DIR%%%s \"%s\" %s", name_of_batch_file, arg_to_batch_file1, arg_to_batch_file2);<br>why = system(cmd_line);<br><br>Wow, gotta love all those percents and double quotes! Note the "from" code was what I was trying, when system() complained about it.
<br><br>I also tried using the short path (using Foo~1 instead of "Foo Bar"). The "~n" also seemed to get stripped by system().<br><br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How about people putting single quotes in filenames, like "This is<br>Dave's File.doc". Who would do a thing like that? Had that blow up a PHP<br>script recently. Grrr...<br><br>-dc<br><br>Nathan C. Smith wrote:
<br>> And that was all we got from Tim as agents from Redmond beat down the door<br>> and took him prisoner.<br>><br>> -Nate<br>><br>><br>> _____<br>><br>> From: Tim Wilson [mailto:<a href="mailto:tim_linux@wilson-home.com">
tim_linux@wilson-home.com</a>]<br>> Sent: Tuesday, September 25, 2007 4:47 PM<br>> To: <a href="mailto:cialug@cialug.org">cialug@cialug.org</a><br>> Subject: [Cialug] OT: Interesting "feature" in Windows
<br>><br>><br>> I ran across a problem today, that I thought some of you might enjoy. A<br>> customer was running a product we talk to in a directory like "C:\Program<br>> Files\Foo Bar\Foo2". In this directory, my app runs a batch file. The
<br>> easiest way to execute the batch file from a C program is to call system(),<br>> right? That's great, except it has a problem with spaces. No problem, I'll<br>> put escaped double quotes around the argument to system(). That too, did
<br>> not work. After doing some Googling, I found something that sounds like<br>> others are experiencing (someone created a bug<br>><br>><br>><br>> ------------------------------------------------------------------------
<br>><br>> _______________________________________________<br>> Cialug mailing list<br>> <a href="mailto:Cialug@cialug.org">Cialug@cialug.org</a><br>> <a href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug
</a><br><br><br>_______________________________________________<br>Cialug mailing list<br><a href="mailto:Cialug@cialug.org">Cialug@cialug.org</a><br><a href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug
</a><br></blockquote></div><br><br clear="all"><br>-- <br>Tim