# haw to save the output of a script in a file ansible 2.0.2

**URL:** <https://forum.ansible.com/t/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2/21087>\
**Category:** Ansible Project\
**Created:** [April 7, 2016, 8:10am UTC](https://forum.ansible.com/t/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2/21087 "2016-04-07T08:10:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![imed\_khaskhoussi](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@imed\_khaskhoussi](https://forum.ansible.com/u/imed_khaskhoussi)\
**Post date:** [April 7, 2016, 8:10am UTC](https://forum.ansible.com/t/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2/21087/1 "2016-04-07T08:10:56Z")

</div>

> down vote[favorite](http://stackoverflow.com/questions/36470297/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2#)  
>   
>   
> |   
>   
>   
> i want to save the output of a command in a file , i tried to use :  
>   
>   
>   
> `<br>- command: ./script1 >> file.txt 2>&1 <br>`  
>   
>   
>   
> but it’s give me an empty file. Is there any other method to save the output of my “script1” in a “file” using ansible 2.0.2 . thank you in advance .  
>   
>   
> |

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 7, 2016, 9:58am UTC](https://forum.ansible.com/t/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2/21087/2 "2016-04-07T09:58:33Z")

</div>

Hi,

You probably need to use the shell module instead of the command module - command runs commands without a shell. To use \>\> and 2\>&1, which are thing that your shell gives you, you need to use the shell module.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![imed\_khaskhoussi](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@imed\_khaskhoussi](https://forum.ansible.com/u/imed_khaskhoussi)\
**Post date:** [April 7, 2016, 10:31am UTC](https://forum.ansible.com/t/haw-to-save-the-output-of-a-script-in-a-file-ansible-2-0-2/21087/3 "2016-04-07T10:31:09Z")

</div>

thank you Jon , it’s really helpful
