Tried executing the .sh file present in the remote server with below code.
String command1="/home/support/test.sh";
try{
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
JSch jsch = new JSch();
Session session=jsch.getSession(user, host, 22);
session.setPassword(password);
session.setConfig(config);
session.connect();
System.out.println("Connected");
Channel channel=session.openChannel("exec");
((ChannelExec) channel).setCommand(command1);
((ChannelExec) channel).setErrStream(System.err);
channel.connect();
channel.disconnect();
session.disconnect();
Content in shell script:
flname="12.log"
yest=`head -1 yes.txt`
filename=$flname.$yest
filename3=${filename}_prod3
scp user@82.xx.xx.xx:/app/12/log/${filename}
/home/support/${filename}
mv ${filename} ${filename3}
today=$( date +"%Y-%m-%d")
java -jar /home/hybris/support/timeoutRprt.jar /home/support/${filename3}
After executing the script present in the remote server from the java class in my desktop, it doesn't create the files(output of jar file present in script) in remote server. But if I manually execute the script through putty, it produces the required files.
What might be case here?