shikhar/sshj — Issue #51: Maintaining State Between execs
Author: bwuest
Created: 2012-01-06 20:13:46+00:00
State: open

If I do the following:

// start a shell
ssh.startSession().startShell();
// change to the /tmp/ directory
ssh.startSession().exec("cd /tmp/").join();
// print out the current directory
Command cmd = ssh.startSession().exec("pwd");
System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
cmd.join();

Shouldn't I see the current directory as /tmp/? I thought that once you start a shell, all subsequent execs would maintain state between the calls, but I am not observing this. It seems when I try to do the above, it always looks like I stay in the initial directory. Is there something I am missing, is there another way to do this, or is this an error?