# ios\_command multiple commands

**URL:** <https://forum.ansible.com/t/ios-command-multiple-commands/29375>\
**Category:** Ansible Project\
**Created:** [January 4, 2019, 7:51pm UTC](https://forum.ansible.com/t/ios-command-multiple-commands/29375 "2019-01-04T19:51:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduardo\_Nunes\_Pereir](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@Eduardo\_Nunes\_Pereir](https://forum.ansible.com/u/Eduardo_Nunes_Pereir)\
**Post date:** [January 4, 2019, 7:51pm UTC](https://forum.ansible.com/t/ios-command-multiple-commands/29375/1 "2019-01-04T19:51:03Z")

</div>

- name: Network Getting Started First Playbook  
connection: network\_cli  
gather\_facts: false  
hosts: lab  
tasks:

- name: run multiple commands on remote nodes  
ios\_command:  
commands:

- show run  
register: output

- name: save output  
copy:  
content: “{{ output.stdout[0] }}”  
dest: “/etc/ansible/backup/{{ inventory\_hostname }}.txt”

Have you had the chance to save a set of multiple commands on file, just save the first one from the list, does anyone have the same scenario?

---

<div class="post-metadata">

**Author:** ![Veera\_Kumar](https://avatars.discourse-cdn.com/v4/letter/v/b5a626/32.png) [@Veera\_Kumar](https://forum.ansible.com/u/Veera_Kumar)\
**Post date:** [January 5, 2019, 5:00am UTC](https://forum.ansible.com/t/ios-command-multiple-commands/29375/2 "2019-01-05T05:00:48Z")

</div>

Hi,

You can give list of commands and all the outputs will register in mentioned variable name. And instead output.stdout[0] just give output.stdout.

But the problem is variable I.e output.stdout will only contain outputs only. Means issued command will not be there.

Try with blockinfile module to have command1  
output of command1  
Command2  
Output of command2

Thanks,  
Veera

---

<div class="post-metadata">

**Author:** ![Eduardo\_Nunes\_Pereir](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@Eduardo\_Nunes\_Pereir](https://forum.ansible.com/u/Eduardo_Nunes_Pereir)\
**Post date:** [January 6, 2019, 2:34am UTC](https://forum.ansible.com/t/ios-command-multiple-commands/29375/3 "2019-01-06T02:34:21Z")

</div>

Tks Kumar, Your tip worked for me.
