I'm trying to run an FNDLOAD
command using Jsch after connecting to my unix server through ssh. But the command is giving me the following error
bash: FNDLOAD: command not found
Also if I try to read any environment variables like JAVA_TOP
, FND_TOP
etc.its not giving any output. But all the other commands like reading a .sh file are working fine using this code. The code is as shown:
import java.io.InputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import java.util.Properties;
public class ShellExecuter {
/**
* @param args
*/
public static void main(String[] args) {
String host = "10.111.111.11";
String user = "username";
String password = "password";
String FND_TOP = "/u01/oracle/fs1/appl/fnd/12.0.0";
String command = "FNDLOAD user/pass O Y DOWNLOAD " + FND_TOP + "/patch/115/import/abc.lct "
+ "/home/applvis/JAVA/abc.ldt PROGRAM APPLICATION_SHORT_NAME=XX "
+ "CONCURRENT_PROGRAM_NAME=UPLOAD_TOOL";
try {
Properties config = new 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(command);
channel.setInputStream(null);
((ChannelExec) channel).setErrStream(System.err);
InputStream in = channel.getInputStream();
channel.connect();
byte[] tmp = new byte[1024];
while (true) {
while (in.available() > 0) {
int i = in.read(tmp, 0, 1024);
if (i < 0) {
break;
}
System.out.print(new String(tmp, 0, i));
}
if (channel.isClosed()) {
System.out.println("exit-status: " + channel.getExitStatus());
break;
}
try {
Thread.sleep(1000);
} catch (Exception ee) {
}
}
channel.disconnect();
session.disconnect();
System.out.println("DONE");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Can anyone please help me in reading environment variables and performing FNDLOAD
commands. I don't understand what am I doing wrong.
PS: FNDLOAD utility
is properly installed on the server. I'm able to achieve the desired result when I execute the same command from putty.
Does anyone have any suggestion or anything to help me with this issue. I'm struck. I have tried many ways but nothing works. Any help is appreciated.