Command 'service --status-all' outputs to stderr and not to stdout, it is a bug?

Asked by bq

Issuing the command
service --status-all | grep network-manager
does not filter the result , because the output of the 'service' program is on stderr and not on stdout. (I know i can use 2>&1 but....) It is intentional, or should I file a bugreport ?

thanks, bq

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Seth Arnold
Solved:
Last query:
Last reply:
Revision history for this message
Best Seth Arnold (seth-arnold) said :
#1

Ha, service is a strange beast.

The [ ? ] output means that the initscript in /etc/init.d/ didn't contain the word 'status)', so service didn't even try to discover the status of the service. It treats these as errors, and reports them to stderr.

The [ - ] or [ + ] output means that the initscript in /etc/init.d/ did contain the word 'status)', so service tries to discover the status of the service, and reports them to stdout.

So, you can only use 'grep' without redirection for the services that appear to support the status command. You've got to know which ones are which. Or, always use redirection. (A shell function to run service --status-all 2>&1 would be a convenient enough way to avoid all that typing. :) Since the author took efforts to implement this behavior, it is unlikely a bug report would result in all the output going to a single file descriptor... it'd probably be closed "works as designed".

Revision history for this message
bq (balique) said :
#2

Thanks Seth Arnold, that solved my question.