# Extract content in the register variable stdout value

**URL:** <https://forum.ansible.com/t/extract-content-in-the-register-variable-stdout-value/32762>\
**Category:** Ansible Project\
**Created:** [April 22, 2020, 6:56pm UTC](https://forum.ansible.com/t/extract-content-in-the-register-variable-stdout-value/32762 "2020-04-22T18:56:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josephsimon\_Arokiara](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@Josephsimon\_Arokiara](https://forum.ansible.com/u/Josephsimon_Arokiara)\
**Post date:** [April 22, 2020, 6:56pm UTC](https://forum.ansible.com/t/extract-content-in-the-register-variable-stdout-value/32762/1 "2020-04-22T18:56:11Z")

</div>

- name: Extracting Hostname

local\_action: command /usr/bin/perl extracturl.pl {{ url }} port

register: port

I can get the value in stdout “80”

“stderr”: “”, “stderr\_lines”: , “stdout”: “80”, “stdout\_lines”: [“80”]

---

<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:** [April 22, 2020, 8:01pm UTC](https://forum.ansible.com/t/extract-content-in-the-register-variable-stdout-value/32762/2 "2020-04-22T20:01:21Z")

</div>

> Hi All,
> 
> I am capturing the script output in the ansible play using register and using it on another role. The register value  
> contains some additional characters.
> 
> - name: Extracting Hostname
> 
> ```
> local\_action: command /usr/bin/perl extracturl\.pl \{\{ url \}\} port
> 
> register: port
> 
> ```
> 
> I can get the value in stdout "80"
> 
> "stderr": "", "stderr\_lines": , "stdout": "80", "stdout\_lines": ["80"]
> 
> Using port.stdout in a another task. Here is the issue. I am getting [u'80'] in {{ port.stdout }} .
> 
> - include\_role:
> 
> ```
> name: roles/telnet
> 
> vars:
> 
> telnet\_port
> 
> \- &quot;\{\{ port\.stdout \}\}&quot;
> 
> ```
> 
> Any idea how to get rid of [u''] . Just I need the port no: 80

vars:  
&nbsp;&nbsp;&nbsp;telnet\_port: "{{ port.stdout }}"

In your task the - turns it into a list.

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

---

<div class="post-metadata">

**Author:** ![Josephsimon\_Arokiara](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@Josephsimon\_Arokiara](https://forum.ansible.com/u/Josephsimon_Arokiara)\
**Post date:** [April 24, 2020, 2:33pm UTC](https://forum.ansible.com/t/extract-content-in-the-register-variable-stdout-value/32762/3 "2020-04-24T14:33:15Z")

</div>

Hi Racke,

Fantastic, Thanks a lot for your reply. Removed - and it worked .

Cheers,  
Joseph
