Sorry - this was false alarm. I was working on my colleague's code that uses JSch and I overlooked a design flaw that caused that problem.
Mit freundlichen Grüßen,
Von: Dudek, Maciej
Gesendet: Freitag, 26. Februar 2010 15:15
Betreff: setting environment variables outside pty
I am using ChannelShell with PTY = false to execute commands. It works just fine, but I can't seem to be able to set environment variables through setEnv() - it has no influence on the environment. My goal ist to set the LANG variable. The same applies to setting this variable through a command execution:
CommandResult cmd = conn.execute("export LANG=POSIX");
System.out.println("return_code = " + cmd.getReturnCode());
CommandResult cmd2 = conn.execute("env | grep LANG");
System.out.println(cmd2.getOutput() + " | return_code = " + cmd2.getReturnCode());
return_code = -1
LANG=de_DE.UTF-8 | return_code = 0
Whereas if I run the Shell example (http://www.jcraft.com/jsch/examples/Shell.java) which has pty enabled, both approaches work fine. That means that the remote machine is set properly. This is from the remote machine:
host:~ # cat /etc/ssh/sshd_config | grep AcceptEnv
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
+-From: "Dudek, Maciej" <Maciej.Dudek@...> --
|_Date: Mon, 1 Mar 2010 12:08:17 +0100 _______________________
|Sorry - this was false alarm. I was working on my colleague's code that
|uses JSch and I overlooked a design flaw that caused that problem.
Ah, you have found the answer by yourself.
It must be good news! Please ignore my previous message.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Get latest updates about Open Source Projects, Conferences and News.