Re: What environment variable affects the "charset" variable?

2019-07-09 Thread Cameron Simpson

On 08Jul2019 12:30, Jon LaBadie  wrote:

On Mon, Jul 08, 2019 at 05:53:22AM -0500, Peng Yu wrote:

`mutt -D` prints 'charset="iso-8859-1"' when it runs in a
non-interactive bash session scheduled by crontab.

But the same command prints 'charset="utf-8"' when it runs in an
interactive bash session. I suspect that this is affected by an
environment variable.

Does anybody know why there is such a difference?


Processes run by cron do not mimic your login environment.
If you need specific things set that are typically set in
.profile etc., you need to set them in your crontab file
or the executed script.


You can wire basic environment variables into the crontab. The usual 
example is the MAILTO environment variable or a basic PATH, but you can 
easily set locale relevant variables as well.


The "locale" command reports the current (computed) locale settings.  
Here's mine just now:


   % locale
   LANG=en_GB.UTF-8
   LANGUAGE=en_AU:en
   LC_CTYPE=en_GB.UTF-8
   LC_NUMERIC="en_GB.UTF-8"
   LC_TIME="en_GB.UTF-8"
   LC_COLLATE=C
   LC_MONETARY="en_GB.UTF-8"
   LC_MESSAGES="en_GB.UTF-8"
   LC_PAPER="en_GB.UTF-8"
   LC_NAME="en_GB.UTF-8"
   LC_ADDRESS="en_GB.UTF-8"
   LC_TELEPHONE="en_GB.UTF-8"
   LC_MEASUREMENT="en_GB.UTF-8"
   LC_IDENTIFICATION="en_GB.UTF-8"
   LC_ALL=

My only actual environment variables are these:

   LANG=en_GB.UTF-8
   LANGUAGE=en_AU:en
   LC_CTYPE=en_GB.UTF-8

You could put something equivalent in your crontab.

See "man locale" and also the other manual entries referenced in its SEE 
ALSO section at the bottom.


Cheers,
Cameron Simpson 


Re: What environment variable affects the "charset" variable?

2019-07-08 Thread Jon LaBadie
On Mon, Jul 08, 2019 at 05:53:22AM -0500, Peng Yu wrote:
> Hi,
> 
> `mutt -D` prints 'charset="iso-8859-1"' when it runs in a
> non-interactive bash session scheduled by crontab.
> 
> But the same command prints 'charset="utf-8"' when it runs in an
> interactive bash session. I suspect that this is affected by an
> environment variable.
> 
> Does anybody know why there is such a difference?

Processes run by cron do not mimic your login environment.
If you need specific things set that are typically set in
.profile etc., you need to set them in your crontab file
or the executed script.

jl
-- 
Jon H. LaBadie j...@jgcomp.com
 11226 South Shore Rd.  (703) 787-0688 (H)
 Reston, VA  20190  (703) 935-6720 (C)


Re: What environment variable affects the "charset" variable?

2019-07-08 Thread Kevin J. McCarthy

On Mon, Jul 08, 2019 at 05:53:22AM -0500, Peng Yu wrote:

I suspect that this is affected by an environment variable.


Most likely.  See 
 
for the environment variables used.  LANG is the normal one to set.


My guess would be the system default codeset is iso-8859-1, but you have 
put a 'export LANG=xx_XX.UTF-8' inside your .bashrc.  Cron won't read 
that by default.  You can internet search "cron .bashrc" and find 
various solutions to the problem.


--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature