# Running knife ssh commands from bash script

**URL:** <https://discourse.chef.io/t/running-knife-ssh-commands-from-bash-script/15568>\
**Category:** Chef Infra (archive)\
**Created:** [July 15, 2019, 12:27pm UTC](https://discourse.chef.io/t/running-knife-ssh-commands-from-bash-script/15568 "2019-07-15T12:27:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Odysseaus](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@Odysseaus](https://discourse.chef.io/u/Odysseaus)\
**Post date:** [July 15, 2019, 12:27pm UTC](https://discourse.chef.io/t/running-knife-ssh-commands-from-bash-script/15568/1 "2019-07-15T12:27:35Z")

</div>

We automate a full streamed pipeline and part of it is bash scripts that call knife ssh commands. If the chef recipe fails on the knife ssh call, the bash script still reports a successful execute. I know why this happens I just need to know how to forward the failed Chef error to the bash script so it can error out properly and exit on a 1.

---

<div class="post-metadata">

**Author:** ![Odysseaus](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@Odysseaus](https://discourse.chef.io/u/Odysseaus)\
**Post date:** [July 15, 2019, 1:27pm UTC](https://discourse.chef.io/t/running-knife-ssh-commands-from-bash-script/15568/2 "2019-07-15T13:27:54Z")

</div>

Another solution that would help would be knowing how to capture the error output from a knife ssh call into a conditional so bash can exit with a error properly.
