<br><br><div><span class="gmail_quote">On 9/25/07, <b class="gmail_sendername">David Champion</b> &lt;<a href="mailto:dchampion@visionary.com">dchampion@visionary.com</a>&gt; 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&#39;t have a problem with it).&nbsp; But system() seemed to strip out &quot;some&quot; of the double quotes, not all.&nbsp; I had double quotes around the path to the batch file, and an argument to the batch file.&nbsp; It appeared to remove the first double quote of the batch file, and the last double quote of the argument.&nbsp; I still have to put double quotes in the argument to putenv(), but it does work.&nbsp; If I put into system() what I put into putenv(), it doesn&#39;t.&nbsp; So my code went from:
<br><br>sprintf(cmd_line, &quot;\&quot;%s%s\&quot; \&quot;%s\&quot; %s&quot;, 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, &quot;DEST_DIR=\&quot;%s\&quot;&quot;, directory_to_batch_file);
<br>putenv(cmd_line);<br>sprintf(cmd_line, &quot;%%DEST_DIR%%%s \&quot;%s\&quot; %s&quot;, 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!&nbsp; Note the &quot;from&quot; 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 &quot;Foo Bar&quot;).&nbsp; The &quot;~n&quot; 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 &quot;This is<br>Dave&#39;s File.doc&quot;. 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>&gt; And that was all we got from Tim as agents from Redmond beat down the door<br>&gt; and took him prisoner.<br>&gt;<br>&gt; -Nate<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; _____<br>&gt;<br>&gt; From: Tim Wilson [mailto:<a href="mailto:tim_linux@wilson-home.com">
tim_linux@wilson-home.com</a>]<br>&gt; Sent: Tuesday, September 25, 2007 4:47 PM<br>&gt; To: <a href="mailto:cialug@cialug.org">cialug@cialug.org</a><br>&gt; Subject: [Cialug] OT: Interesting &quot;feature&quot; in Windows
<br>&gt;<br>&gt;<br>&gt; I ran across a problem today, that I thought some of you might enjoy.&nbsp;&nbsp;A<br>&gt; customer was running a product we talk to in a directory like &quot;C:\Program<br>&gt; Files\Foo Bar\Foo2&quot;.&nbsp;&nbsp;In this directory, my app runs a batch file.&nbsp;&nbsp;The
<br>&gt; easiest way to execute the batch file from a C program is to call system(),<br>&gt; right?&nbsp;&nbsp;That&#39;s great, except it has a problem with spaces.&nbsp;&nbsp;No problem, I&#39;ll<br>&gt; put escaped double quotes around the argument to system().&nbsp;&nbsp;That too, did
<br>&gt; not work.&nbsp;&nbsp;After doing some Googling, I found something that sounds like<br>&gt; others are experiencing (someone created a bug<br>&gt;<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------
<br>&gt;<br>&gt; _______________________________________________<br>&gt; Cialug mailing list<br>&gt; <a href="mailto:Cialug@cialug.org">Cialug@cialug.org</a><br>&gt; <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