4

I'm using vnstat together with conky. To show the monthly traffic I'm mixing vnstat and grep to find the month. The command to collect the data is

${execi 3600 vnstat -m -i wlan0 | grep "$(date "+%h")" | awk '{print $3 $4}'}

but the problem is that vnstat returns the month in English (Dec for December) and date returns it in Portuguese (Dez for Dezembro).

So my command is not working for the monthly traffic. Any help?

Sigur
  • 2,431

2 Answers2

6

You need to export LANG to date. Assuming that execi invokes a POSIX-compliant shell to do the heavy lifting (note: I don't know if it does or not, your mileage may vary), something like the following should work:

${execi 3600 vnstat -m -i wlan0 | grep "$(LC_ALL=C date "+%h")" | awk '{print $3 $4}'}
Chris Down
  • 125,559
  • 25
  • 270
  • 266
3

To run a command in a don't-bother-me-about-locales mode, set the environment variable LC_ALL. This overrides all locale settings. The don't-bother-me locale is called C (or POSIX, they are synonyms).

export LC_ALL=C; vnstat -m -i wlan0 | grep "$(date "+%h")" | awk '{print $3 $4}'

This sets all error messages to English, all dates to US dates, sorting to byte order, and printable characters to ASCII.

See set LC_* but not LC_ALL for more details.