I have found a problem in our FC8 linux machines with the LANG variable when running a command through ssh.
在通过ssh运行命令时,我发现FC8 linux机器中有一个带LANG变量的问题。
When in a terminal, I can see that my LANG variable is "es_ES"
在终端中,我可以看到我的LANG变量是"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"
如果我通过ssh连接回机器,没有问题,$LANG仍然是“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...
但是如果我尝试使用ssh运行一个命令,那么这个变量是未定义的…
[angelv@italia ~]$ ssh italia 'echo $LANG'
LANG: Undefined variable.
[angelv@italia ~]$
Does anybody know where I should look to find the culprit?
有人知道我应该到哪里去找罪犯吗?
3 个解决方案
#1
3
Quoth the SSH manual:
说SSH手册:
If command is specified, it is executed on the remote host instead of a login shell.
如果指定了命令,它将在远程主机上执行,而不是登录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.
登录shell的行为与非登录shell的行为非常不同,最明显的一点是,它们通常不提供登录名.profile文件。有关更多细节,请参阅shell文档。
#2
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.
在linux上,您的地区变量通常在/usr/share/locale中列出。您应该检查服务器machin他们在本地使用什么。它可能与你的机器不同。
EDIT: sorry I mistake the question.
编辑:对不起,我弄错了问题。
in bash you should do
在bash中,您应该这么做
export LANG="es_ES"
in other shell you may have to use setenv
instead of export
在其他shell中,您可能必须使用setenv而不是export
#3
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:
通过调用您的shell并请求它充当登录shell,您可以绕过ssh的这一特性。
ssh italia "sh -l -c 'echo $LANG'"
Depending on the actual shell you're using, the required option might be -l
or something else.
根据您使用的实际shell,所需的选项可能是-l或其他什么。
#1
3
Quoth the SSH manual:
说SSH手册:
If command is specified, it is executed on the remote host instead of a login shell.
如果指定了命令,它将在远程主机上执行,而不是登录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.
登录shell的行为与非登录shell的行为非常不同,最明显的一点是,它们通常不提供登录名.profile文件。有关更多细节,请参阅shell文档。
#2
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.
在linux上,您的地区变量通常在/usr/share/locale中列出。您应该检查服务器machin他们在本地使用什么。它可能与你的机器不同。
EDIT: sorry I mistake the question.
编辑:对不起,我弄错了问题。
in bash you should do
在bash中,您应该这么做
export LANG="es_ES"
in other shell you may have to use setenv
instead of export
在其他shell中,您可能必须使用setenv而不是export
#3
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:
通过调用您的shell并请求它充当登录shell,您可以绕过ssh的这一特性。
ssh italia "sh -l -c 'echo $LANG'"
Depending on the actual shell you're using, the required option might be -l
or something else.
根据您使用的实际shell,所需的选项可能是-l或其他什么。