# how to use an pipe like \< \< in ansible ?

**URL:** <https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388>\
**Category:** Ansible Project\
**Created:** [August 21, 2018, 5:45pm UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388 "2018-08-21T17:45:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrik\_Schuetze](https://avatars.discourse-cdn.com/v4/letter/h/e9bcb4/32.png) [@Henrik\_Schuetze](https://forum.ansible.com/u/Henrik_Schuetze)\
**Post date:** [August 21, 2018, 5:45pm UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388/1 "2018-08-21T17:45:44Z")

</div>

i want to use a command like:

read CURRENT\_LOG CURRENT\_POS \< \<( mysql -BNe “SHOW MASTER STATUS”); echo CURRENT\_LOG=$CURRENT\_LOG CURRENT\_POS=$CURRENT\_POS

(credits: [https://dba.stackexchange.com/questions/34934/how-to-retrieve-master-log-position-and-master-log-file-in-shell-script](https://dba.stackexchange.com/questions/34934/how-to-retrieve-master-log-position-and-master-log-file-in-shell-script))

But ansible dont unterstand “\< \<”

What can i do ?

---

<div class="post-metadata">

**Author:** ![dmartin](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@dmartin](https://forum.ansible.com/u/dmartin)\
**Post date:** [August 21, 2018, 6:22pm UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388/2 "2018-08-21T18:22:48Z")

</div>

Use the shell module.

---

<div class="post-metadata">

**Author:** ![Henrik\_Schuetze](https://avatars.discourse-cdn.com/v4/letter/h/e9bcb4/32.png) [@Henrik\_Schuetze](https://forum.ansible.com/u/Henrik_Schuetze)\
**Post date:** [October 10, 2018, 9:45am UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388/3 "2018-10-10T09:45:07Z")

</div>

no. this doesnt work, because the shell command only support one “\<”

---

<div class="post-metadata">

**Author:** ![tkuratom](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@tkuratom](https://forum.ansible.com/u/tkuratom)\
**Post date:** [October 10, 2018, 6:09pm UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388/4 "2018-10-10T18:09:10Z")

</div>

Without an error message I'm not sure whether I'm looking at the same  
thing but this looks like a portability problem with the shell script  
you are attempting to use.

In /bin/sh (implemented by bash), I get the following error:

$ /bin/sh \*[stable-2.7] (10:54:10)  
sh-4.4$ read HELLO\_WORLD \<\<(/bin/expr 1 + 1) ; echo $HELLO\_WORLD  
sh: syntax error near unexpected token `('

Similarly /bin/bash:

$ /bin/bash \*[stable-2.7] (10:54:31)  
[badger@peru:16 stable-2.7]$ read HELLO\_WORLD \<\<(/bin/expr 1 + 1) ;  
echo $HELLO\_WORLD  
bash: syntax error near unexpected token `('

In /bin/zsh, I can get it to work, though:  
$ /bin/zsh \*[stable-2.7] (10:54:36)  
[pts/16@peru /srv/ansible/stable-2.7]$ read HELLO\_WORLD \<\<(/bin/expr 1  
+ 1) ; echo $HELLO\_WORLD  
2

So if you have zsh installed, you could write your ansible command like this:  
$ ansible localhost -m shell -a 'executable=/bin/zsh read HELLO\_WORLD  
\<\<(/bin/expr 1 + 1) ; echo $HELLO\_WORLD'  
localhost | CHANGED | rc=0 \>\>  
2

And the equivalent playbook:

---

<div class="post-metadata">

**Author:** ![dch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dch/32/7132_2.png) [@dch](https://forum.ansible.com/u/dch)\
**Post date:** [October 10, 2018, 7:20pm UTC](https://forum.ansible.com/t/how-to-use-an-pipe-like-in-ansible/28388/5 "2018-10-10T19:20:30Z")

</div>

Try using ‘tee -a …’ in the pipeline.

Dave
