Getting IO exception when running Linux command in Java -
i'm writing java app in windows connect linux machine through ssh. i'm getting following exception:
java.io.ioexception: cannot run program ssh: createprocess error=2, cannot find specified file.
code:
process p = runtime.getruntime().exec("ssh root@xxx.xxx.xxx.xxx ls");
while running command in cmd working, not through java. ssh in path
environmental vars.
you need interpreter understand ssh command:
process p = runtime.getruntime().exec(new string[]{"cmd", "ssh root@xxx.xxx.xxx.xxx ls"});
Comments
Post a Comment