[smartmontools-support] Discuss: smartctl --json: should output messages to stderr on fail

Eike Dierks foonlyboy at gmail.com
Sat Jan 28 01:51:16 CET 2023


Hi at the smartmon team

I'd like to suggest a change to the current behaviour of
  smartctl --json
regarding how to show errors on stderr

When I execute:
  smartctl --json nosuchdevice
no error messages show up on stderr.

All the errors are perfectly described in the json[messages] on stdout.
But there is nothing on stderr.

I'd like to suggest to change that behaviour.
If a command goes wrong, it should write the problems to stderr.
The reporting of problems should not be suppressed.
This is why stderr was invented for.

Let me give a use case:
- display the temparature of a disk
- build a wrapper script to extract the value from the json output
- show the errors on fail

At the current state,
I have to parse the json for the error messages
just to write them to stderr, myself.

I'd like t suggest:
that any errors are always output to stderr,
even, when smartctl is invoked with --json

It's much more easy to suppress stderr, if you need that:
 smartctl --json nochsuchdevice 2>/dev/null
instead of to have to reconstruct the error messages from the json.

---
best regards
~eike









































that errors a reported in the json on stdout,
but they are not reported on stderr.

try:
  sudo smartctl -a --json nosuchdevice > /dev/null


More information about the Smartmontools-support mailing list