Skip to content
Advertisement

Not able to execute a .csh script using jsch library – Exit 1

Im trying to use Jsch to execute a .csh script on a remote server. I am able to execute commands like cp, mv and ls. But when I try to execute a script that internally references some environment variables, the script is exiting with status 1. There is an INTERNAL_ENV_VARIABLE referenced inside script.sh that is not accessible when i run using exec. Is there some way I can run the .csh script from exec that will take care of this dependency ?

Using the shell instead of exec is not an option as there are multiple authentication levels when we open a shell and would make the test framework we are developing, dependent on multiple credentials.

Commands I am calling to navigate to the script directory and execute the script.

JavaScript

console output

JavaScript

Method to Execute the Command : executeCommand

JavaScript

Method to Create a Session : createSession

JavaScript

Advertisement

Answer

JavaScript

Each of these command invocations will run independently of the others. Notably, each command will start with the same working directory–probably the home directory of whatever user you used to log in–and the cd command that you invoke first won’t have any effect on the other commands that you run.

If you want to string together a sequence of commands, you have to run them in one invocation:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement