# Backup info saved in TXT file is not in readable format, please help

**URL:** <https://forum.ansible.com/t/backup-info-saved-in-txt-file-is-not-in-readable-format-please-help/34639>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 18, 2021, 7:25am UTC](https://forum.ansible.com/t/backup-info-saved-in-txt-file-is-not-in-readable-format-please-help/34639 "2021-02-18T07:25:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [February 18, 2021, 7:25am UTC](https://forum.ansible.com/t/backup-info-saved-in-txt-file-is-not-in-readable-format-please-help/34639/1 "2021-02-18T07:25:37Z")

</div>

Below is my playbook to backup info from router and save it to a file. But when i open the TXT file in ansible controller, backup info is very difficult to read. Please look at the screenshot in below link: [https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing](https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing)

Iam running ansible network automation device in GNS3. Is it because iam opening this file in ansible/linux device that the data is so dis-organized? If i were to open this TXT file in windows PC, will the data be in a readable format or should i change my script to make data more readable?

- name: show version and other user level commands

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 18, 2021, 8:00am UTC](https://forum.ansible.com/t/backup-info-saved-in-txt-file-is-not-in-readable-format-please-help/34639/2 "2021-02-18T08:00:58Z")

</div>

> Below is my playbook to backup info from router and save it to a file. But when i open the TXT file in ansible  
> controller, backup info is very difficult to read. Please look at the screenshot in below  
> link: [https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing](https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing)  
> \<[https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing&gt](https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing&gt);
> 
> Iam running ansible network automation device in GNS3. Is it because iam opening this file in ansible/linux device that  
> the data is so dis-organized? If i were to open this TXT file in windows PC, will the data be in a readable format or  
> should i change my script to make data more readable?
> 
> &nbsp;&nbsp;\*
> 
> &nbsp;&nbsp;&nbsp;&nbsp;name: show version and other user level commands
> 
> &nbsp;&nbsp;&nbsp;&nbsp;hosts: R1
> 
> &nbsp;&nbsp;&nbsp;&nbsp;gather\_facts: false
> 
> &nbsp;&nbsp;&nbsp;&nbsp;connection: local
> 
> &nbsp;&nbsp;&nbsp;&nbsp;tasks:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: run multiple commands on remote nodes
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ios\_command:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;commands:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ show ip arp  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ show version  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ show int status  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ show int description
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: print\_output
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: save output to a file copy: content="{{ print\_output.stdout\_lines }}" dest="./output/{{ inventory\_hostname  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}.txt"

You can either use print\_output.stdout (string) or turn print\_output.stdout\_line (list) into a string:

print\_output.stdout\_lines | join('\n')

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [February 20, 2021, 2:42pm UTC](https://forum.ansible.com/t/backup-info-saved-in-txt-file-is-not-in-readable-format-please-help/34639/3 "2021-02-20T14:42:28Z")

</div>

Hi,

I found the solution after a little research  
\n is the ASCII symbol for new line. Ansible was catching the raw output the router was sending over the wire to the terminal emulator software, and for some reason it was getting “\n” rather than “\n”. So below config saves output in proper format.

copy: content=“{{ print\_output.stdout | **replace(‘\n’, ‘\n’) }**}” dest=“./output/router1.txt”

Thanks for trying to help me.
