File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes when using Runtime.getRuntime.exec(shell_cmd) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark " when using Runtime.getRuntime.exec(shell_cmd)" Watch " when using Runtime.getRuntime.exec(shell_cmd)" New topic
Author when using Runtime.getRuntime.exec(shell_cmd)

Raja Mirrah

Joined: Jun 23, 2009
Posts: 26
Hi All,

I am getting the following exception. when running a shell command

ksh -c export TERM=vt100; ssh -p 2261 -N -f -L<local-port>:loghost:2361 IP_ADDRESS

localport will be replaced by valid port number greater than 1024.

The following are the exception which i am receiving. SSHksh: not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(
at java.lang.ProcessImpl.start(
at java.lang.ProcessBuilder.start(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at PLAMConnection.startup(
at PLAMConnection.processRqst(
at PLAMConnectionMgr.worker2(
at PLAMConnectionMgr.worker(
at PLAMConnectionMgr.receive(
at PLAMListener.listen(

Can anyone tell me the exact reason for this error?

Your early response is highly appreciated.

Warm Regards,
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Redirecting out- and input with > and < is a feature of your shells, but not possible from runtime.getRuntime().exec ...

And maybe more than one command, concatenated with ; is a problem?

Here is an article about pitfalls with runtime:
I agree. Here's the link:
subject: when using Runtime.getRuntime.exec(shell_cmd)
It's not a secret anymore!