1. "system()" vs "system_exec()" problem
- Posted by jjnick at cvn.com Apr 29, 2001
- 516 views
This is a multi-part message in MIME format. ------=_NextPart_000_003C_01C0D097.B82140C0 charset="Windows-1252" I am pretty sure that the behavior of "system_exec()" is not desired: =20 - "testargs.exe" will print a confirmation message that it found 2 = arguments - Calling "testargs.exe" with "system_exec()" with the following = arguments: 'testargs "1 1" "2 2"' produces nothing . . . - Yet, Calling "testargs.exe" with "system()" with the same arguments = produces the correct result, "2" =20 Test it out yourself with the following code: =20 "TESTARGS.EXW" include win32lib.ew without warning =20 constant Win =3D create( Window, "System calls", = 0, Default, Default, 170, 150, 0 ), =20 SystemExecButton =3D create( PushButton, "Use system_exec()", = Win, 10, 10, 140, 40, 0 ), SystemButton =3D create( PushButton, "Use system()", = Win, 10, 60, 140, 40, 0 ) =20 sequence OScommand OScommand =3D "testargs \"1 1\" \"2 2\"" =20 global procedure onClick_SystemExecButton() object result result =3D system_exec(OScommand, 0) result =3D message_box(sprintf( "%s", { "When testargs.exe is passed = the following: 'testargs \"1 1\" \"2 2\"', nothing happens . . ." } ), = "Test arguments", MB_ICONINFORMATION+MB_TASKMODAL ) end procedure =20 =20 global procedure onClick_SystemButton() object result =20 system (OScommand, 0) result =3D message_box(sprintf( "%s", { "Yet, when testargs.exe is = passed the same arguments: 'testargs \"1 1\" \"2 2\"', testargs.exe = recognizes the 2 arguments" } ), "Test arguments", MB_ICONINFORMATION+MB_TASKMODAL ) end procedure =20 =20 onClick[SystemExecButton] =3D routine_id( "onClick_SystemExecButton" ) onClick[SystemButton] =3D routine_id( "onClick_SystemButton" ) =20 WinMain( Win, Normal ) "TESTARGS.C" =20 #include <stdio.h> #include <stdlib.h> =20 int main( int argc, char *argv[] ) { =20 if ( argc =3D=3D 3 ) // argc is always at least "1" printf("\nFound 2 arguments . . .\n"); getchar(); return( 0 ); } As all of you know, including double quotes (") on the command line is = perfectly legal under a DOS box . . . Obviously, there is something with the way "system_exec()" processes = double quotes ("). ------=_NextPart_000_003C_01C0D097.B82140C0 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dwindows-1252"> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>I am pretty sure that the behavior of=20 "system_exec()" is not desired:<BR> <BR>- "<FONT=20 face=3D"Courier New">testargs.exe</FONT>" will print a confirmation = message that=20 it found 2 arguments<BR>- Calling "<FONT face=3D"Courier = New">testargs.exe</FONT>"=20 with "<FONT face=3D"Courier New">system_exec()</FONT>" with the = following=20 arguments: <FONT face=3D"Courier New">'testargs "1 1" "2 2"</FONT>' = produces=20 nothing . . .<BR>- Yet, Calling "<FONT face=3D"Courier = New">testargs.exe</FONT>"=20 with "<FONT face=3D"Courier New">system()</FONT>" with the same = arguments produces=20 the correct result, "2"<BR> <BR>Test it out yourself with the = following=20 code:<BR> <BR>"TESTARGS.EXW"</FONT></DIV><FONT face=3DArial = size=3D2> <DIV><BR><FONT face=3D"Courier New" size=3D1>include = win32lib.ew<BR>without=20 warning<BR> <BR>constant=20 Win &nbs= p; =20 =3D create( Window, "System=20 calls", 0, Default, Default, = 170, 150,=20 0 ),<BR> <BR> =20 SystemExecButton =3D create( PushButton, "Use system_exec()",=20 Win, 10, 10, = 140, 40, 0 ),<BR> =20 SystemButton =3D create( PushButton, "Use=20 system()", = Win, =20 10, 60, 140, 40, 0 = )<BR> <BR>sequence=20 OScommand<BR>OScommand =3D "testargs \"1 1\" \"2 = 2\""<BR> <BR>global=20 procedure onClick_SystemExecButton()<BR> object = result<BR> result =3D=20 system_exec(OScommand, 0)<BR> result =3D message_box(sprintf( "%s", = { "When=20 testargs.exe is passed the following: 'testargs \"1 1\" \"2 2\"', = nothing=20 happens . . ." } ), "Test arguments", MB_ICONINFORMATION+MB_TASKMODAL = )<BR>end=20 procedure &nbs= p;  = ; = =20 <BR> <BR>global procedure onClick_SystemButton()<BR> object=20 result<BR> <BR> system (OScommand, 0)<BR> result =3D=20 message_box(sprintf( "%s", { "Yet, when testargs.exe is passed the same=20 arguments: 'testargs \"1 1\" \"2 2\"', testargs.exe recognizes the 2 = arguments"=20 } ),<BR> "Test arguments", MB_ICONINFORMATION+MB_TASKMODAL = )<BR>end=20 procedure &nbs= p;  = ; = =20 <BR> <BR>onClick[SystemExecButton] =3D routine_id( = "onClick_SystemExecButton"=20 )<BR>onClick[SystemButton] =3D routine_id(=20 "onClick_SystemButton" )<BR> <BR>WinMain( Win, Normal = )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1><BR><FONT face=3DArial=20 size=3D2>"TESTARGS.C"<BR></FONT> <BR>#include = <stdio.h><BR>#include=20 <stdlib.h><BR> <BR>int main( int argc, char *argv[] )=20 {<BR> <BR> if ( argc =3D=3D 3 ) // argc is always at least=20 "1"<BR> printf("\nFound 2 arguments . . = .\n");<BR> =20 getchar();<BR> return( 0 );<BR>}</FONT></FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>As all of you know, including double = quotes (") on=20 the command line is perfectly legal under a DOS box . . .</DIV> <DIV><BR>Obviously, there is something with the way "<FONT=20 face=3D"Courier New">system_exec()</FONT>" processes double quotes=20 ------=_NextPart_000_003C_01C0D097.B82140C0--
2. Re: "system()" vs "system_exec()" problem
- Posted by jjnick at cvn.com Apr 29, 2001
- 468 views
This is a multi-part message in MIME format. ------=_NextPart_000_0060_01C0D099.8B807840 charset="Windows-1252" I need to expound upon this. I need to pass arguments to my c program = that contain paths with spaces in them, ie, "C:\My Documents\hello.html" = . . . hence the reason for the double quotes (") . . . ----- Original Message -----=20 From: jjnick at cvn.com=20 To: EUforum=20 Sent: Sunday, April 29, 2001 10:32 AM Subject: "system()" vs "system_exec()" problem I am pretty sure that the behavior of "system_exec()" is not desired: - = "testargs.exe" will print a confirmation message that it found 2 = arguments- Calling "testargs.exe" with "system_exec()" with the = following arguments: 'testargs "1 1" "2 2"' produces nothing . . .- Yet, = Calling "testargs.exe" with "system()" with the same arguments produces = the correct result, "2" ------=_NextPart_000_0060_01C0D099.8B807840 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dwindows-1252"> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I need to expound upon this. I = need to pass=20 arguments to my c program that contain paths with spaces in them, ie, = "C:\My=20 Documents\hello.html" . . . hence the reason for the double quotes (") . = .=20 .</FONT></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Djjnick at cvn.com = href=3D"mailto:jjnick at cvn.com">jjnick at cvn.com</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3DEUforum at topica.com=20 href=3D"mailto:EUforum at topica.com">EUforum</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Sunday, April 29, 2001 = 10:32=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> "system()" vs = "system_exec()"=20 problem</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial = size=3D2></FONT><FONT=20 face=3DArial size=3D2></FONT><FONT face=3DArial size=3D2></FONT><FONT = face=3DArial=20 size=3D2></FONT><FONT face=3DArial size=3D2></FONT><FONT face=3DArial=20 size=3D2></FONT><BR></DIV><PRE> >>>>> The = Euphoria Mailing List <<<<< </PRE><PRE><FONT face=3DArial size=3D2>I am pretty sure that the = behavior of "system_exec()" is not desired:<BR> <BR>- "<FONT = face=3D"Courier New">testargs.exe</FONT>" will print a confirmation = message that it found 2 arguments<BR>- Calling "<FONT face=3D"Courier = New">testargs.exe</FONT>" with "<FONT face=3D"Courier = New">system_exec()</FONT>" with the following arguments: <FONT = face=3D"Courier New">'testargs "1 1" "2 2"</FONT>' produces nothing . . = .<BR>- Yet, Calling "<FONT face=3D"Courier New">testargs.exe</FONT>" = with "<FONT face=3D"Courier New">system()</FONT>" with the same = arguments produces the correct result, = ------=_NextPart_000_0060_01C0D099.8B807840--
3. Re: "system()" vs "system_exec()" problem
- Posted by Derek Parnell <ddparnell at bigpond.com> Apr 29, 2001
- 525 views
Hi "jjnick", instead of the system() and system_exec() functions, you can use the win32lib functions. try out... atom rc sequence startdir startdir = "C:\\whatever" rc = shellExecuteEx( "open", "testargs", "\"1 1\" \"2 \"", startdir, SW_SHOWNORMAL, 0) ------ Derek Parnell Melbourne, Australia "To finish a job quickly, go slower."
4. Re: "system()" vs "system_exec()" problem
- Posted by jjnick at cvn.com Apr 29, 2001
- 495 views
Thanks, but isn't this a problem with "system_exec()", ie, shouldn't it support these type of arguments, or am I doing something wrong? What if somebody trys doing this in MS-DOS mode, ie, not in Windows . . . ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Subject: Re: "system()" vs "system_exec()" problem > instead of the system() and system_exec() functions, you can use the > win32lib functions. > > try out... > atom rc > sequence startdir > > startdir = "C:\\whatever" > > rc = shellExecuteEx( "open", "testargs", "\"1 1\" \"2 \"", > startdir, SW_SHOWNORMAL, 0) > ------ > Derek Parnell > Melbourne, Australia > "To finish a job quickly, go slower."