SSH Remote connection with Environment Variables
I am writing a java code to connect to the Unix remote server using java-ganymed plugin (also tried with JSch).
I need to run a shell script located at the remote server, which uses some Environment Variables of that login. My login is successful and script does execute but not to completion. I checked that the environment variables are not completely loaded as compared to running an interactive login shell like Putty etc(used 'env' command).
Connection conn = new Connection("host");
boolean testAuth = conn.authenticateWithPassword("user", "pwd");
Session sess = conn.openSession();
sess.execCommand(Commands); //"Commands" is a string variable with "sh" command.
I tried running /etc/profile, .bashrc etc prior to my script. The script moves one step ahead but again halts. So its evident that a few environment variables were loaded but not all. I need a work around to ensure all the environment variables are loaded for the Java non-interactive session. I do NOT have the root permission for the remote server.