# Setting environment before an rc script is executed



## mamalos (Oct 4, 2012)

The title speaks for itself. OK, if I could set some system-wide environmental variables (locale is my interest), it'd do the trick, but a formal way of setting the environment of some deamon before it runs would be juuuust fine!

The details (for those who're interested):

I'm trying to run an application through www/tomcat7 that connects to a database that I have converted (not necessarily correctly...) from MSSQL to MySQL, which at some point returns an error whose message is:

```
???en_US.null???
```

...which stinks of locale... (of course, something is executed wrong and maybe it's trying to display a message acquired from the database whose default character set is utf8).

Moreover, at the same time, catalina complains about the date format:

```
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '10/31/2010' for column 'LBPLOCKDATE' at row 1
```

WHICH, as you can see from the error, is rendering date in a wrong way since it assumes that the month is 31 and the date is 10, which should be the opposite. Due to the fact that this program's target group is Greek, (all servers are "Greek enabled" as well) it stinks a bit of locale, since the "Greek way" of showing a date is usually dd/mm/yyyy whereas in US (and not only...) applications one usually sees dates being displayed like this: mm/dd/yyyy.

So I assume if I set the LOCALE accordingly, maybe both problems will be resolved...(not very optimistic though...). 

For a quick test I tried to inject LC_ALL=en_US.UTF-8 before the command to be executed in tomcat's rc script, which of course made the script useless...(don't shout, I know it's wrong, just playing around a bit!).

Thanx all in advance...


----------

