erotavlas
December 8th, 2013, 10:02 AM
Hi,
I'm newbie of Java and I have a trouble on executing a command of shell where I use a pipe. I read on the web that it is possible to do something like this:
String[] cmd = {
"/bin/sh",
"-c",
"ls /etc | grep release"
};
Process p = Runtime.getRuntime().exec(cmd);
This works well. If I try something more complex like this
ssh user@ip 'tar -jcf - file1 file2 ' | tar -C /path -jxf -
it does not work and I receive the exit code 255. Do you have any idea?
Thank you
I'm newbie of Java and I have a trouble on executing a command of shell where I use a pipe. I read on the web that it is possible to do something like this:
String[] cmd = {
"/bin/sh",
"-c",
"ls /etc | grep release"
};
Process p = Runtime.getRuntime().exec(cmd);
This works well. If I try something more complex like this
ssh user@ip 'tar -jcf - file1 file2 ' | tar -C /path -jxf -
it does not work and I receive the exit code 255. Do you have any idea?
Thank you