# how to get DaysLeft value in stdout\_line?

**URL:** <https://forum.ansible.com/t/how-to-get-daysleft-value-in-stdout-line/37048>\
**Category:** AWX Project\
**Created:** [August 29, 2022, 8:09pm UTC](https://forum.ansible.com/t/how-to-get-daysleft-value-in-stdout-line/37048 "2022-08-29T20:09:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abel\_Laime](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Abel\_Laime](https://forum.ansible.com/u/Abel_Laime)\
**Post date:** [August 29, 2022, 8:09pm UTC](https://forum.ansible.com/t/how-to-get-daysleft-value-in-stdout-line/37048/1 "2022-08-29T20:09:08Z")

</div>

Hi,  
I need to only get the “DaysLeft” value in my “register” output:

REGISTER:  
{  
“changed”: true,  
“invocation”: {  
“module\_args”: {  
“removes”: null,  
“\_raw\_params”: “wmic /namespace:\\root\CIMV2\TerminalServices PATH Win32\_TerminalServiceSetting WHERE (\_\_CLASS !="") CALL GetGracePeriodDays”,  
“chdir”: null,  
“creates”: null,  
“output\_encoding\_override”: null,  
“cmd”: null,  
“argv”: null,  
“stdin”: null  
}  
},  
“cmd”: “wmic /namespace:\\root\CIMV2\TerminalServices PATH Win32\_TerminalServiceSetting WHERE (\_\_CLASS !="") CALL GetGracePeriodDays”,  
“rc”: 0,  
“stdout”: “Executing (\\SERVER01\root\CIMV2\TerminalServices:Win32\_TerminalServiceSetting.ServerName="SERVER01")-\>GetGracePeriodDays()\r\r\nMethod execution successful.\r\r\nOut Parameters:\r\ninstance of \_\_PARAMETERS\r\n{\r\n\tDaysLeft = 94;\r\n\tReturnValue = 0;\r\n};\r\n”,  
“stderr”: “\r\n”,  
“start”: “2022-08-29 20:02:32.821675”,  
“end”: “2022-08-29 20:02:33.084685”,  
“delta”: “0:00:00.263009”,  
“stdout\_lines”: [  
“Executing (\\SERVER01\root\CIMV2\TerminalServices:Win32\_TerminalServiceSetting.ServerName="SERVER01")-\>GetGracePeriodDays()”,  
“”,  
“Method execution successful.”,  
“”,  
“Out Parameters:”,  
“instance of \_\_PARAMETERS”,  
“{”,  
“\tDaysLeft = 94;”,  
“\tReturnValue = 0;”,  
“};”  
],  
“stderr\_lines”: [  
“”  
],  
“\_ansible\_no\_log”: false  
}

Playbook:

- name: output  
debug: msg=“{{ r.stdout\_lines.DaysLeft }} days”

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [August 30, 2022, 11:30am UTC](https://forum.ansible.com/t/how-to-get-daysleft-value-in-stdout-line/37048/2 "2022-08-30T11:30:00Z")

</div>

Hello, your question seems to be about using Ansible, not about AWX. [https://groups.google.com/g/ansible-project](https://groups.google.com/g/ansible-project) is the best place to visit for user questions about Ansible.

That being said, because you used the command module the output comes in two forms stdout and stdout\_lines. They are the same just one is a string (stdout) and the other is an array of string (stdout\_lines). So you will need to use some string manipulation to get the data. This will be very dependent on how reliable your commands output will be. I would probably just use some regular expressions. Assuming your variable is called “r” you should be able to do something like:

- **name** : output  
**debug** :  
**msg** : “{{ r.stdout | regex\_replace(‘\n’, ‘’, multiline=false) | regex\_replace(‘._DaysLeft = ([0-9]+);._’, ‘\1’) }}”

The Ansible group may be able to point you to better methods to achieve this.

-The AWX Team

---

<div class="post-metadata">

**Author:** ![Abel\_Laime](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Abel\_Laime](https://forum.ansible.com/u/Abel_Laime)\
**Post date:** [August 30, 2022, 12:03pm UTC](https://forum.ansible.com/t/how-to-get-daysleft-value-in-stdout-line/37048/3 "2022-08-30T12:03:37Z")

</div>

Thanks!  
this worked correctly.  
Bye
