I am running my scripts on machines with different locales and at least who produces different dates depending on the locale.
Code:
$ ssh davidlt@machine 'who -s'
davidlt pts/0 Jan 12 16:54 (empty.lt)
$ who -s
david console Jan 13 07:08
$ env -i LANG=en_US.UTF-8 ssh davidlt@lxbuild170 'who -s'
davidlt pts/0 2012-01-12 16:54 (empty.lt)
$ ssh davidlt@machine 'who -s'
davidlt pts/0 Jan 12 16:54 (empty.lt)
In the first example SSH send LANG and LC_* variables to the remote machine. So, lt_LT.UTF-8 was set. In the second example the same locale was used on my local machine. On the third example I have tried running a clean environment, which does not have any LANG or LC_* set and setting it myself. Now I got the date I wanted.
Code:
$ LANG=en_US.UTF-8 who -s
david console Jan 13 07:08
$ LANG=en_US.UTF-8 bash -c 'who -s'
david console Jan 13 07:08
$ LANG=en_US.UTF-8 bash -c 'env' | grep LANG
LANG=en_US.UTF-8
$ env -i LANG=lt_LT.UTF-8 ssh davidlt@lxbuild170 'who -s'
davidlt pts/0 2012-01-12 16:54 (empty.lt)
Well, after playing more I can see that changing LANG, which also modifies all LC_* does not give any result. Even if variable is set, the default locale is used (lt_LT.UTF-8). The last example illustrates that very well.
It looks like env does the magic forcing command to run in the different locale, but only en_US.UTF-8? But it doesn't work on the local machine commands.
How do I force command to use en_US.UTF-8 locale?
Thanks!
David