# Append shell script output on remote server

**URL:** <https://forum.ansible.com/t/append-shell-script-output-on-remote-server/30227>\
**Category:** Ansible Project\
**Created:** [April 30, 2019, 4:56pm UTC](https://forum.ansible.com/t/append-shell-script-output-on-remote-server/30227 "2019-04-30T16:56:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Kolan](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Rahul\_Kolan](https://forum.ansible.com/u/Rahul_Kolan)\
**Post date:** [April 30, 2019, 4:56pm UTC](https://forum.ansible.com/t/append-shell-script-output-on-remote-server/30227/1 "2019-04-30T16:56:35Z")

</div>

In Ansible is there any way i can append the shell script out to in one file.  
basically I have script which does some validation like services status up after the OS upgrade.  
I want to execute the script on remote machine & append the output in remote system somewhere under “/tmp/file”.

---

<div class="post-metadata">

**Author:** ![Matthew\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Matthew\_Davis](https://forum.ansible.com/u/Matthew_Davis)\
**Post date:** [May 8, 2019, 12:30am UTC](https://forum.ansible.com/t/append-shell-script-output-on-remote-server/30227/2 "2019-05-08T00:30:52Z")

</div>

Yes, the easiest way would be to just direct it in the shell command.

`  
shell: ./myBinary \> /tmp/file

`

Or if you want Ansible to still see the stdout, do:

`  
shell: ./myBinary | tee /tmp/file

`

This only deals with stdout. Let me know if you want to capture stderr too. (There are equivilent ways of capturing both.)

The alternative is registering the output and saving the content in the next step.

`

- shell: ./myBinary  
register: shellTask

- copy:  
content: shellTask.stdout  
path: /tmp/file

`

Regards,  
Matt
