dnLL Posted March 10, 2021 Share Posted March 10, 2021 (edited) 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 March 10, 2021 by dnLL Quote Link to comment
dnLL Posted March 10, 2021 Author Share Posted March 10, 2021 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. Quote Link to comment
dnLL Posted March 10, 2021 Author Share Posted March 10, 2021 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. Quote Link to comment
dnLL Posted March 10, 2021 Author Share Posted March 10, 2021 (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 March 10, 2021 by dnLL Quote Link to comment
dnLL Posted March 10, 2021 Author Share Posted March 10, 2021 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. Quote Link to comment
Recommended Posts
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.