tags:

views:

42

answers:

3

Hi,

I have found a problem in our FC8 linux machines with the LANG variable when running a command through ssh.

When in a terminal, I can see that my LANG variable is "es_ES"

[angelv@italia ~]$ echo $LANG
es_ES

If I connect back to my machine through ssh, there are no problems and $LANG is still "es_ES"

[angelv@italia ~]$ ssh italia
Last login: Mon Jul 26 12:51:12 2010 from XXXXXXXXXXXX
[angelv@italia ~]$ echo $LANG
es_ES
[angelv@italia ~]$

But if I try to run a command with ssh, then that variable is undefined...

[angelv@italia ~]$ ssh italia 'echo $LANG'
LANG: Undefined variable.
[angelv@italia ~]$ 

Does anybody know where I should look to find the culprit?

A: 

On linux, your locale variable is generally listed in /usr/share/locale. You should check on the server machin what local they use. It may differ from your machine.

EDIT: sorry I mistake the question.

in bash you should do

export LANG="es_ES"

in other shell you may have to use setenv instead of export

Phong
note that LANG is set properly when an interactive shell was started but not with direct command execution; that was the clue that it wasn't a missing `export` as I too thought on first look.
msw
+3  A: 

Quoth the SSH manual:

If command is specified, it is executed on the remote host instead of a login shell.

Login shells behave quite differently than non-login shells, most notably here in that they don't usually source the the login .profile files. See your shell documentation for more detail.

msw
A: 

You may be able to work around this feature of ssh by invoking your shell and asking it to act like a login shell:

ssh italia "sh -l -c 'echo $LANG'"

Depending on the actual shell you're using, the required option might be -l or something else.

Greg Hewgill