# Help writing remote command result to file.

**URL:** <https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563>\
**Category:** Ansible Developer\
**Created:** [February 13, 2014, 1:14pm UTC](https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563 "2014-02-13T13:14:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![txemi](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@txemi](https://forum.ansible.com/u/txemi)\
**Post date:** [February 13, 2014, 1:14pm UTC](https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563/1 "2014-02-13T13:14:13Z")

</div>

I am having problems doing something I think it should be really easy.

I am writting a rule that remote execs a command and I want the results stored locally. (It is an nmap command)

I think I could do it two rules, one command rule and one fetch rule to download de result, but I do not like it because I should find a temp original non used multiprocess safe remote path to store the result.

I know I can register one variable in rules file with stdout command result, but I do not find some way to store this variable in a local file, that is what i finally want.

Is there any way to do that?

thanks,  
txemi

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [February 13, 2014, 1:24pm UTC](https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563/2 "2014-02-13T13:24:32Z")

</div>

I’d be tempted to use the template module with a template that just outputs a variable, and pass the results.stdout as that variable.

If you have further questions, this is really a topic for ansible-project list rather than ansible-devel.

Will

---

<div class="post-metadata">

**Author:** ![txemi](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@txemi](https://forum.ansible.com/u/txemi)\
**Post date:** [February 13, 2014, 10:49pm UTC](https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563/3 "2014-02-13T22:49:21Z")

</div>

Thanks, I will post nest questions in ansible-project.

"copy" module with "content" argument worked for me. The only thing is  
that "ntop.stdout" was not raw "[" formatted instead and copy module  
complaint about that.

- command: nmap -T4 -F -oX -  
${ansible\_eth0.ipv4.network}/${ansible\_eth0.ipv4.netmask}  
&nbsp;&nbsp;register: nmap  
- local\_action: copy content="${nmap.stdout}"  
dest=${rootdir}/data/nodes/${nodename}/scans/${filename}

complains:

failed: [192.168.57.101] =\> {"failed": true}  
msg: this module requires key=value arguments (['content=\<?xml version=1.0?...

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 14, 2014, 12:42am UTC](https://forum.ansible.com/t/help-writing-remote-command-result-to-file/14563/4 "2014-02-14T00:42:27Z")

</div>

Public service announcement:

Old style ${foo} variables are deprecated since 1.4 and should be expressed as {{ foo }}

The old style will no longer work in 1.6
