2

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?

1
  • My shell is tcsh, so the file that is not loaded in a non-login shell is ~/.login Following that file solved the issue. Thanks for the replies. Jul 27, 2010 at 9:08

3 Answers 3

3

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.

0

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

1
  • 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
    Jul 27, 2010 at 8:54
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.