From: Andrzej Taramina <andrzej@ch...> - 2005-06-10 18:22:38
I've done an extended version of the Ant sshexec task which lets you nest multiple
commands to be executed on the remote host.
I keep the session open, but have been creating a new ChannelExec for each command
submission. Problem with that is that your "environment" is not retained on the remote
host between individual commands. For example, if I do two command, "cd .." and "ls -a"
the directory is no longer set to the parent by the time the ls is executed.
Is there a way to use a ChannelExec so that you can execute multiple commands, but not
have it reset you back to the beginning regarding the "environment"...sort of like a
normal telnet session?
I'm thinking of something like not creating a new ChannelExec each time. Can you do a
connect(), disconnect() and another connect() on the same channel to do this? Multiple
connect() calls without an intervening disconnet()? Or something else? Or maybe I can't
get there from here.
I looked at the code for Channel, ChannelSession and ChannelExec, but it's pretty poor
code, with zero comments, so on cursory inspection I'm not sure what it's doing.
Any/all assistance would be very much appreciated!
Thanks from a JSCH newbie.
+-From: "Andrzej Taramina" <andrzej@...> --
|_Date: Fri, 10 Jun 2005 14:22:33 -0400 ___________
|I keep the session open, but have been creating a new ChannelExec
|for each command
|submission. Problem with that is that your "environment" is
|not retained on the remote host between individual commands.
It is from the spec for sshd. The remote sshd will fork a process
for each ChannelExec.
|Is there a way to use a ChannelExec so that you can execute multiple
|commands, but not have it reset you back to the beginning regarding the
|"environment"...sort of like a normal telnet session?
You can use ChannelShell.
If fact, I had consulted some 'huge' company to solve such requirements and
I have heard they have now used our code all over the world.
4-1 OHMACHI 1-CHOME AOBA-KU,
SENDAI, MIYAGI 980-0804 Japan.