[SOLVED] Broken pipe error when filtering output of asterisk -rx 'sip show peers'

Hello.

I see the following error message in asterisk when executing CLI commands from Linux bash while filtering the output with ‘grep -g’ (output suppress)

The following command is executed without problems when there’s no output suppression (option -g):
/usr/sbin/asterisk -rx 'sip show peers' | grep 'SIPTRUNK'

And this one triggers the error:
/usr/sbin/asterisk -rx 'sip show peers' | grep -q 'SIPTRUNK'

This is the following snippet from the log:
[2017-03-13 13:18:46] ERROR[28549]: utils.c:1332 ast_carefulwrite: write() returned error: Broken pipe

Is it possible that this standard output filtering is messing with asterisk?
Any help is appreciated.

System:
CentOS 6.5
Certified asterisk 11.6-cert13

Looks like expected behaviour to me. grep -q exits immediately on a match, which will cause a broken pipe error.

1 Like

thank you for your explanation!