Desmond Hume
Desmond Hume

Reputation: 8607

Find out which shell PHP is using

I'm trying to execute a piped shell commands like this

set -o pipefail && command1 | command2 | command3

from a PHP script. The set -o pipefail part is to make the pipe break as soon as any of the commands fails. But the commands results in this:

sh: 1: set: Illegal option -o pipefail

whereas it runs fine from the terminal. Maybe explicitly specifying which shell PHP CLI should use (i.e. bin/bash) when executing shell commands could solve the problem or is there better way out?

Upvotes: 1

Views: 440

Answers (2)

melpomene
melpomene

Reputation: 85757

You can always run bash -c 'set -o pipefail && command1 | command2 | command3' instead.

Upvotes: 2

Andreas Linden
Andreas Linden

Reputation: 12721

you can find it out by doing

echo `echo $SHELL`;

Upvotes: 1

Related Questions