Re: Runtime.exec()

Randall R Schulz <[email protected]>
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
On Wednesday 19 September 2007 18:17, Avinash Lakshman wrote:
> Hi All
>
> I am noticing this weird behavior with Runtime.exec() and was
> wondering could help me understanding this better. Basically I run
> Runtime.getRuntime().exec("scp -r <source> <target>"). This never
> performs the scp. However if I copy this into a .sh file and execute
> the .sh file then scp does happen. What is going on? Is there a way
> to execute the command directly? Does it have anything to do with any
> permission settings?

What is the host OS? What is the default shell it uses to interpret
command strings? Describe what appears in the "<source>" and "<target>"
positions. How are you handling the I/O streams of the
java.lang.Process that is returned by Runtime.exec()?

You're relying on a native shell to interpret that command line, and
this is inherentely dependent on the language implemented by that
command interpreter, which is usually OS-dependent.

I consider it preferable to use the String array forms of
Runtime.exec(). That avoids the use of the native command interpreter.


> Thanks
> A


Randall Schulz

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.