I have a bash script on a server that contains a command which is not on the default path.
If I use a terminal to ssh to the server and execute the script, it works fine (because the directory where the command is located is added to the path). However, if I try to execute the command via JSch's CommandExec, I got a "command not found" error.
Is there anyway to add the additional directory to the path when executing the script via JSch?
Note that I cannot modify the script on the server. It has to run as is.
myscript.sh
...
mycommand
...
JSch code:
JSch jsch = new JSch();
Session session = jsch.getSession(user, host, port);
session.connect();
ChannelExec channelExec = (ChannelExec)session.openChannel("exec");
channelExec.setCommand("/path/to/myscript.sh");
channelExec.connect();
Thank you