Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: problem with multiword args and Runtime.exec() Date: Fri, 11 Jan 2013 21:36:03 +0000 (UTC) Organization: UK Free Software Network Lines: 30 Message-ID: References: <05a24a02-1ac3-4866-ba2b-20c488793b96@googlegroups.com> NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1357940163 24620 84.45.235.129 (11 Jan 2013 21:36:03 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Fri, 11 Jan 2013 21:36:03 +0000 (UTC) User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.java.programmer:21337 On Fri, 11 Jan 2013 08:33:39 -0800, Aryeh M. Friedman wrote: > 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 > example 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 was a java program]): > > rdiff-backup --remote-schema "ssh -C -p9222 %s rdiff-backup --server" > username@remoteserver::/path_to/filestobackup /path_to/backedupfiles Something like Runtime r = new Runtime(); String sc = String.format("ssh -C -p9222 %s rdiff-backup -- server", hostName); r.exec("rdiff-backup", "--remote-schema", sc, "username@remoteserver::/path_to/filestobackup " + "/path_to/backedupfiles"); ought to work. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |