X-Received: by 10.66.80.34 with SMTP id o2mr10295118pax.9.1357933444060; Fri, 11 Jan 2013 11:44:04 -0800 (PST) X-Received: by 10.50.163.67 with SMTP id yg3mr166203igb.12.1357933444018; Fri, 11 Jan 2013 11:44:04 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f6no2262979pbd.1!news-out.google.com!6ni101623pbd.1!nntp.google.com!f6no2262972pbd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Fri, 11 Jan 2013 11:44:03 -0800 (PST) In-Reply-To: <4600dcb5-1819-4e5b-aeae-70162d97144d@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=130.76.32.78; posting-account=_7xgmwoAAADi7iXKBO-oX5zbCfSzsCV0 NNTP-Posting-Host: 130.76.32.78 References: <05a24a02-1ac3-4866-ba2b-20c488793b96@googlegroups.com> <4600dcb5-1819-4e5b-aeae-70162d97144d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <00bca6a0-7ce5-4e0c-8374-e3a8b5bed32d@googlegroups.com> Subject: Re: problem with multiword args and Runtime.exec() From: FredK Injection-Date: Fri, 11 Jan 2013 19:44:04 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:21335 On Friday, January 11, 2013 11:41:00 AM UTC-8, FredK wrote: > On Friday, January 11, 2013 8:33:39 AM UTC-8, Aryeh M. Friedman wrote: >=20 > > No matter what version of Runtime.exec I call I can not make a arg that= has multiple words in it (*NOT* multiple args but a single one) for exampl= e if I need to issue the following command in unix I can not find a way to = do the stuff in "'s as a single arg [the called program requires this... i.= e. it *MUST NOT* be treated as different elements of String[] args if it wa= s a java program]): >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > rdiff-backup --remote-schema "ssh -C -p9222 %s rdiff-backup --server" u= sername@remoteserver::/path_to/filestobackup /path_to/backedupfiles >=20 >=20 >=20 > Your program gets the quotes string as a single argument. >=20 > If you want to pass that string as a single argument to something >=20 > like system(), you have to ensure that there are quotes around the >=20 > multi-word argument. >=20 >=20 >=20 > For example, assume arg1 contains the multiword value. >=20 > You cannot just say: >=20 > sprintf( buffer, "ls %s", arg1 ); >=20 > system( buffer ); >=20 >=20 >=20 > you have to use >=20 > sprintf( buffer, "ls '%s'", arg1 ); >=20 > system( buffer ); >=20 >=20 >=20 >=20 >=20 > --=20 >=20 > Fred K Oops - answered it as "C". However, the same concept goes for Java String buffer =3D "ls '" + arg1 + "'";