0

I'm trying to run the following command over SSH with JSch :

AlgoName -m /tmp/input1.txt -f /tmp/input2.txt > /tmp/output.txt

The value of exitStatus is 2. The command does not work over SSH with Jsch but it run successfully on the server.

My code:

        ChannelExec channelExec = (ChannelExec) s.openChannel("exec");
        channelExec.setCommand(command);         
        channelExec.connect();

        int exitStatus = channelExec.getExitStatus();
        channelExec.disconnect();

1 Answers1

0

The algorithm I'm trying to run is written in Perl, actually when I execute the remote SSH command via JSCH, the user profile used to run the command are not loaded, so the environment variables are not loaded either.

The solution is to load the profile when I run the command, like this:

bash -l -c 'AlgoName -m /tmp/input1.txt -f /tmp/input2.txt > /tmp/output.txt'