# Shell command with problems since 2.0.2.0

**URL:** <https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289>\
**Category:** Ansible Project\
**Created:** [April 27, 2016, 6:15am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289 "2016-04-27T06:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [April 27, 2016, 6:15am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/1 "2016-04-27T06:15:31Z")

</div>

My task calls this

`

```auto
shell: free | awk '/Mem:/ {print $4}'

```

`

and the output is empty. Up until Version 2.0.1.0 this correctly output the 4th string of the second line from the free command.

When changing that to

`

```auto
shell: echo "free | awk '/Mem:/ {print $4}'" > /tmp/output

```

`

we get

`free | awk '/Mem:/ {print }'`

in the file /tmp/out which demonstrates that the $4 is skipped for some not obvious reason.

Q1: Is this a new bug?

Q2: Is there any other way to get the result from the “free” output?

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [April 27, 2016, 6:33am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/2 "2016-04-27T06:33:09Z")

</div>

Sorry, just realized that suddenly the shell command is switching to a German context when used through Ansible. I don’t know why, because when I ssh into my host I still get everything in English. But through Ansible the output from the shell command is in German.

Q3: Has that changed in version 2.0.2.0?  
Q4: How can I change that to the previous behaviour?

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [April 27, 2016, 8:26am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/3 "2016-04-27T08:26:28Z")

</div>

Sorry, I don’t have answer to your questions but I wonder why are you using shell module for this task? Why don’t you just:

`ansible host01 -m setup -a "filter=ansible_memfree_mb"`

or in playbook:

`setup: filter=ansible_memfree_mb`

Edgars

trešdiena, 2016. gada 27. aprīlis 08:15:31 UTC+2, Jürgen Haas rakstīja:

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [April 27, 2016, 8:54am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/4 "2016-04-27T08:54:12Z")

</div>

@Edgars, this is a great answer to my Q2 😉 And of course this is a much better way of getting this kind of information and I’m confused why I did it in such a complicated way. This solved the problem I’m having nicely, thanks a lot.

However, just to make sure that we do not run into unintended issues elsewhere, this issue just made me wonder how I could force language to English for Ansible sessions just to make sure I always operate in a defined environment. If anyone knew, I’d be glad to receive a hint.

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [April 27, 2016, 9:15am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/5 "2016-04-27T09:15:47Z")

</div>

My best advice is: use -vvvv for verbose output and see what parameters and variables ansible is using… You will probably see something like this:

`LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8`

Perhaps you can change it in your ansible.cfg like [https://docs.ansible.com/ansible/intro\_configuration.html#module-lang](https://docs.ansible.com/ansible/intro_configuration.html#module-lang)

`module_lang = en_US.UTF-8`

Edgars

trešdiena, 2016. gada 27. aprīlis 08:15:31 UTC+2, Jürgen Haas rakstīja:

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [April 27, 2016, 10:49am UTC](https://forum.ansible.com/t/shell-command-with-problems-since-2-0-2-0/21289/6 "2016-04-27T10:49:47Z")

</div>

Perfect, that’s it ! Thanks @Edgars
