Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #10667
| From | Nigel Wade <nmw-news@ion.le.ac.uk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: (java.lang.Runtime()).exec(new String[]) ... |
| Date | 2011-12-12 14:31 +0000 |
| Message-ID | <9kmhheFk40U1@mid.individual.net> (permalink) |
| References | <1323496863.17965@nntp.aceinnovative.com> |
On 10/12/11 06:01, lbrt chx _ gemale wrote:
> Something like this:
> ~
> Process proc = (java.lang.Runtime()).exec((new String[]{"ls", "-l", "/media/sda1/Physical_Basis.flv"}));
> ~
> works just fine.
> ~
> Why doesn't something like, say:
> ~
> Process proc = (java.lang.Runtime()).exec((new String[]{"date;", "time","ls", "-l", "/media/sda1/Physical_Basis.flv;", "date;"}));
> ~
> work?
> ~
Besides the other problems, even if the code were executable it would
fail because you are attempting to run a sequence of commands.
Process.exec() runs one command, the first argument. The rest of the
string elements are arguments to that command. It will not run a
sequence of commands as implied by the ";" ending each of the first two
commands. That requires you to use a shell to interpret the command
sequence.
--
Nigel Wade
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
(java.lang.Runtime()).exec(new String[]) ... lbrt chx _ gemale - 2011-12-10 06:01 +0000 Re: (java.lang.Runtime()).exec(new String[]) ... Lew <lewbloch@gmail.com> - 2011-12-09 23:00 -0800 Re: (java.lang.Runtime()).exec(new String[]) ... Roedy Green <see_website@mindprod.com.invalid> - 2011-12-10 02:44 -0800 Re: (java.lang.Runtime()).exec(new String[]) ... Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-12-12 14:31 +0000
csiph-web