locale LC_ALL issue


5 posts in this topic Last Reply

Recommended Posts

I have a bash script that displays the following error before it even starts (the error is displayed as soon as bash is called/launched):

 

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)

 

I have to get rid of this error, the script is launched through inetd by my monitoring server and it can't parse the output because of that error at the beginning. So I checked locale:

 

root@server:~# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

 

Seems like an easy fix would be to change LC_ALL to en_US.UTF-8 here. How do I do that in Unraid?

Edited by dnLL
Link to post

I tried editing my .bash_profile without any success. I tried adding export LC_ALL=C and export LC_ALL="en_US.UTF-8" but I still get the same error, it's as if the .bash_profile wasn't loaded when the script is started by xinetd.

Link to post

Here is a full example:

 

root@server:~# cat /usr/bin/check_mk_agent
#!/bin/bash
echo "test"

root@server:~# /usr/bin/check_mk_agent
test

root@server:~# telnet localhost 6556
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)
test
Connection closed by foreign host.

 

Link to post
Posted (edited)

Something more interesting:

 

root@server:~# cat /usr/bin/check_mk_agent
#!/bin/bash
locale

root@server:~# /usr/bin/check_mk_agent
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF8"
LC_NUMERIC="en_US.UTF8"
LC_TIME="en_US.UTF8"
LC_COLLATE="en_US.UTF8"
LC_MONETARY="en_US.UTF8"
LC_MESSAGES="en_US.UTF8"
LC_PAPER="en_US.UTF8"
LC_NAME="en_US.UTF8"
LC_ADDRESS="en_US.UTF8"
LC_TELEPHONE="en_US.UTF8"
LC_MEASUREMENT="en_US.UTF8"
LC_IDENTIFICATION="en_US.UTF8"
LC_ALL=

root@server:~# telnet localhost 6556
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=en_US
Connection closed by foreign host.

root@server:~# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US.utf8

 

xinetd launching the bash script is trying for some reason en_us which isn't supported by Unraid.

Edited by dnLL
Link to post

Fixed it by editing /etc/rc.d/rc.xinetd, changed all the en_us to en_us.utf-8. Now I need to script this to prevent this from happening again next reboot.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.