3

I've been trying to use JSch, and I made a small GUI.

However, when I tried to use cd work_folder, there will be a exit code 0, which means successful, however, the current directory does not change.

BUT, when I tried ls, pwd, mkdir zzzz, all these commands are executed successfully.

Has anyone has this problem before?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user1157751
  • 2,427
  • 6
  • 42
  • 73
  • 1
    How are you executing the `cd`, sounds to me like you're doing the equivalent of `ssh user@server cd dir` - this runs the cd then closes the pipe. You need to establish an ssh session. Maybe take a look at sftp. – Boris the Spider Feb 16 '13 at 14:03
  • Thanks for the reply, First I open the session using user@server, then open a channel("exec") then calling CD blabla. BUT, the channels closes everything when I finish executing an instruction. I think that is supposed to happen? – user1157751 Feb 16 '13 at 14:07
  • Yep, I just had a look at sftp, and the sample code works pretty well, I'm still trying to understand what it's doing though. Thanks for the comment! – user1157751 Feb 16 '13 at 14:25
  • @user1157751 Can you please share the solution with us. I'm facing the same issue. Cd is not working. – Anil Reddy Yarragonda Mar 05 '17 at 15:05

0 Answers0