Hi All,

Please check the below program while is not executing, when the unix command's having \&\& is used.
The following command copies the src folder to dest folder with out data loss ...

import java.io.*;
import java.util.*;
public class Sample
public static void main(String[] args)
try {

String ExCmd = "ssh oradev@dev.excl.com cd /u01/11510/devdb/9.2.0/slax \\&\\& /bin/tar cf - . | ssh oratest@test.excl.com cd /d01/AppsTest/testappl2 \\&\\& /bin/tar -xf - > test.log";

System.out.println("Command to execute : "+ExCmd);

Process SshProc = (Runtime.getRuntime()).exec(ExCmd);

// any error message?
StreamReader errorStream = new StreamReader(SshProc.getErrorStream(), "DEBUG");

// any output?
StreamReader outputStream = new StreamReader(SshProc.getInputStream(), "OUTPUT");

// kick them off

int pp =SshProc.waitFor();
System.out.println("command execution value: "+pp);

}catch(Exception e) {


class StreamReader extends Thread
InputStream is;
String type;

StreamReader(InputStream is, String type)
this.is = is;
this.type = type;

public void run()
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null) {
System.out.println(type + ">" + line);
} catch (IOException ioe)

When this is executed iam getting process value as "0".

But nothing is copying to target ..

So to resolve this i have created a script .. and passed arguments to that script and chaged command as follows :

String ExCmd = "sh /home/juser/movedir.sh oradev@dev.excl.com /u01/11510/devdb/9.2.0/slax /bin/tar oratest@test.excl.com /d01/AppsTest/testappl2 /bin/tar /home/juser/test";

Then it is executing fine. But in my scenario iam restricted to use scripts.

So plz can any body have a solution for this.

Thanks, SN