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,
Maciej Dudek
Von: Dudek, Maciej
Gesendet: Freitag, 26. Februar 2010 15:15
An: 'jsch-users@lists.sourceforge.net'
Betreff: setting environment variables outside pty
Hello,
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());
The results:
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
Yours faithfully,
Maciej Dudek
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users