I am managing to execute a shell script on a remote server using JSch exec using the helpful examples provided here. I can see the echoes being returned from the script and the exit status at the end is 0 - so all looks good at first glance.
However, the problem is that the script itself calls out to other scripts, and these appear to be completely ignored, just skipped over.
The script calls other scripts directly. i.e. the first line of the script is something like:
script_two.sh
Could anyone advise of any way to overcome this? I did start to look into the "shell" channel instead of "exec", but this may be tricky in my case because before giving the user access to the system, the server presents a form to fill in (name, number, why are you logging in, etc) - I haven't yet been able to to programmatically fill in and submit this form, so I would like to stick with exec if possible.
I am new to all this, so any help/advice would be most welcome!
Code snippet below. As I said, this appears to work, but the sh script represented by "scriptFileName" int he code calls other sh scripts, and these are not executed.
Many thanks in advance for any help, J
JSch jsch = new JSch();
JSch.setConfig(FileTransferConstants.STRICT_HOST_KEY_CHECKING, "no");
Session session = jsch.getSession(username, hostIPAddress, port);
session.setPassword(password);
session.connect();
//create the execution channel over the session
ChannelExec channelExec = (ChannelExec)session.openChannel("exec");
channelExec.setCommand(scriptFileName);
channelExec.connect();