# Using local\_action with shell module can't deal with the command line arugment.

**URL:** <https://forum.ansible.com/t/using-local-action-with-shell-module-cant-deal-with-the-command-line-arugment/19282>\
**Category:** Ansible Project\
**Created:** [September 17, 2015, 3:12am UTC](https://forum.ansible.com/t/using-local-action-with-shell-module-cant-deal-with-the-command-line-arugment/19282 "2015-09-17T03:12:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user73](https://avatars.discourse-cdn.com/v4/letter/u/4bbf92/32.png) [@user73](https://forum.ansible.com/u/user73)\
**Post date:** [September 17, 2015, 3:12am UTC](https://forum.ansible.com/t/using-local-action-with-shell-module-cant-deal-with-the-command-line-arugment/19282/1 "2015-09-17T03:12:30Z")

</div>

I want to echo something to a file using local\_action and shell module. When I use `echo -e`, ansible will treat `-e` as string to print rather than a command line argument. See below:

```auto
$ cat t.yaml
- hosts: localhost
  remote_user: root
  gather_facts: False
  tasks:
    - name: test
      local_action: shell echo -e abc

```

```auto
$ ansible-playbook -vv t.yaml

PLAY [localhost] **************************************************************

TASK: [test] ******************************************************************
<127.0.0.1> REMOTE_MODULE command echo -e abc #USE_SHELL
changed: [localhost -> 127.0.0.1] => {"changed": true, "cmd": "echo -e abc", "delta": "0:00:00.006123", "end": "2015-09-17 11:04:00.381722", "rc": 0, "start": "2015-09-17 11:04:00.375599", "stderr": "", "stdout": "-e abc", "warnings": []}

PLAY RECAP ********************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0

```

The stdout filed shows that ansible echo a string that is `-e abc` which include the command line argument `-e`. I also test it without local\_action option in the playbook. Its behavior is normal as I expected.

```auto
$ cat t.yaml
- hosts: localhost
  remote_user: root
  gather_facts: False
  tasks:
    - name: test
      shell: echo -e abc

```

```auto
$ ansible-playbook -vv t.yaml

PLAY [localhost] **************************************************************

TASK: [test] ******************************************************************
<localhost> REMOTE_MODULE command echo -e abc #USE_SHELL
changed: [localhost] => {"changed": true, "cmd": "echo -e abc", "delta": "0:00:00.001969", "end": "2015-09-17 03:06:25.842056", "rc": 0, "start": "2015-09-17 03:06:25.840087", "stderr": "", "stdout": "abc", "warnings": []}

PLAY RECAP ********************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0

```

This time the stdout does not include the `-e` argument.

Is there something else I need to do when use local\_action and shell module to execute command with argument?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 17, 2015, 11:34am UTC](https://forum.ansible.com/t/using-local-action-with-shell-module-cant-deal-with-the-command-line-arugment/19282/2 "2015-09-17T11:34:33Z")

</div>

The problem is likely due to /bin/sh being something like dash which doesn’t support some arguments. You might have to specify an executable= for /bin/bash or similar
