|
From: WELLS, R. K. <ROG...@sa...> - 2003-07-15 12:39:00
|
<br><font size=2 face="sans-serif">FWIW the popen option works as expected here. - gcc (GCC) 3.2.3 (mingw special 20030425-1)</font>
<br><font size=2 face="sans-serif">OS is win2000 (sp4)</font>
<br><font size=2 face="sans-serif"><br>
-<br>
Roger Wells, P.E.<br>
SAIC<br>
221 Third St<br>
Newport, RI 02840<br>
401-847-4210 (voice)<br>
401-849-1585 (fax)<br>
ro...@mt...<br>
</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>"Luke Dunstan" <cod...@ho...></b></font>
<br><font size=1 face="sans-serif">Sent by: min...@li...</font>
<p><font size=1 face="sans-serif">07/14/2003 11:37 PM</font>
<br><font size=1 face="sans-serif">Please respond to mingw-users</font>
<br>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To: <min...@li...></font>
<br><font size=1 face="sans-serif"> cc: </font>
<br><font size=1 face="sans-serif"> Subject: Re: [Mingw-users] popen() and spawnlp() fail</font></table>
<br>
<br>
<br><font size=2 face="Courier New"><br>
1. Have you tried passing the full path to diff.exe instead of just "diff"?<br>
2. Try printing the value of the PATH environment variable, and what<br>
operating system are you using? There have been issues in the past on Win9x<br>
due to MSYS converting PATH to forward slashes.<br>
3. It may not matter but you don't need to pass spaces (" ") between the<br>
arguments because that is handled by spawn.<br>
4. AFAIK you cannot pass redirection options (>) to spawn() because those<br>
are handled by the shell (cmd.exe/command.com) which is bypassed by spawn(),<br>
like it would be for exec(). If the problem is just with finding diff.exe,<br>
then you should instead try popen() again, or use system() because it calls<br>
the shell.<br>
<br>
Luke<br>
<br>
----- Original Message ----- <br>
From: <ml...@mu...><br>
To: "mingw-user" <min...@li...><br>
Sent: Tuesday, July 15, 2003 9:09 AM<br>
Subject: [Mingw-users] popen() and spawnlp() fail<br>
<br>
<br>
> Hi,<br>
><br>
> when trying to get the output of diff with popen(), a getc() only returns<br>
> -1, and if I try to run diff with spawnlp(), with the output written to a<br>
file,<br>
> the diff executable is never found even though it is in the path; the path<br>
> variable contains the path to diff, and copying diff.exe into the<br>
directory<br>
> of the program doesn't help.<br>
> I'm pretty sure that I must be doing something wrong, but I'm stumped to<br>
> what it is and therefore would appreciate a shove into the right<br>
direction.<br>
> Here's the function in question:<br>
><br>
> /* emulation of readpipe */<br>
> static void<br>
> readpipe(char* diff_prog, char* filename1, char* filename2,<br>
> char* options_str) {<br>
> int exec_string_length=0;<br>
> char* diff_exec=NULL;<br>
><br>
> /* calc the length string, taking into account the spaces and NULL */<br>
> exec_string_length=strlen(diff_prog)+1;<br>
> exec_string_length+=strlen(filename1)+1;<br>
> exec_string_length+=strlen(filename2)+1;<br>
> if (options_str)<br>
> {<br>
> exec_string_length+=strlen(options_str)+1;<br>
> diff_exec=(char*)malloc(exec_string_length);<br>
> if (!diff_exec) return NULL;<br>
> /* assemble commandline */<br>
> sprintf(diff_exec,"%s %s %s %s",diff_prog,options_str,<br>
> filename1,filename2);<br>
> }<br>
> else<br>
> {<br>
> diff_exec=(char*)malloc(exec_string_length);<br>
> if (!diff_exec) return NULL;<br>
> /* assemble commandline */<br>
> sprintf(diff_exec,"%s %s %s",diff_prog,filename1,filename2);<br>
> }<br>
> /* read-only pipe */<br>
> /* input_file=popen(diff_exec,"r");*/<br>
> spawnlp(P_WAIT,diff_prog,diff_prog," ",filename1," ",filename2,<br>
> " > diff.out",NULL);<br>
> input_file=fopen("diff.out","rt");<br>
> free(diff_exec);<br>
> }<br>
><br>
><br>
> TIA,<br>
> -- <br>
> Bernd<br>
<br>
<br>
-------------------------------------------------------<br>
This SF.Net email sponsored by: Parasoft<br>
Error proof Web apps, automate testing & more.<br>
Download & eval WebKing and get a free book.<br>
www.parasoft.com/bulletproofapps1<br>
_______________________________________________<br>
MinGW-users mailing list<br>
Min...@li...<br>
<br>
You may change your MinGW Account Options or unsubscribe at:<br>
https://lists.sourceforge.net/lists/listinfo/mingw-users<br>
</font>
<br>
<br>
<br>
|