# /bin/bash output in ansible playbook as a conditional statement

**URL:** <https://forum.ansible.com/t/bin-bash-output-in-ansible-playbook-as-a-conditional-statement/31453>\
**Category:** Ansible Project\
**Created:** [October 11, 2019, 5:58am UTC](https://forum.ansible.com/t/bin-bash-output-in-ansible-playbook-as-a-conditional-statement/31453 "2019-10-11T05:58:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Manish\_Kumar](https://forum.ansible.com/u/Manish_Kumar)\
**Post date:** [October 11, 2019, 5:58am UTC](https://forum.ansible.com/t/bin-bash-output-in-ansible-playbook-as-a-conditional-statement/31453/1 "2019-10-11T05:58:00Z")

</div>

Dear All,

Is it possible to get the output from .sh file and compare with “Apache Tomcat/9.0.26” and if condition is true proceed for next step ?

---

<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:** [October 11, 2019, 6:09am UTC](https://forum.ansible.com/t/bin-bash-output-in-ansible-playbook-as-a-conditional-statement/31453/2 "2019-10-11T06:09:08Z")

</div>

> Dear All,
> 
> Is it possible to get the output from .sh file and compare with "Apache Tomcat/9.0.26" and if condition is true proceed  
> for next step ?

The condition in "when" is evaluated before running the task. You need an additional task where you can apply the  
condition based on the values in output.stdout.

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

---

<div class="post-metadata">

**Author:** ![Manish\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Manish\_Kumar](https://forum.ansible.com/u/Manish_Kumar)\
**Post date:** [October 11, 2019, 6:19am UTC](https://forum.ansible.com/t/bin-bash-output-in-ansible-playbook-as-a-conditional-statement/31453/3 "2019-10-11T06:19:04Z")

</div>

Thanks Racke !!

Let me try it .
