detect stderr writes when combined

Sten Daniel Soersdal netslists at gmail.com
Fri Jun 8 17:26:07 UTC 2007


Robin Becker wrote:
> This is possibly a stupid question, but I would like to have a 
> particular sh script stdout and stderr combined, but at least detect 
> when stderr has been used.
> 
> In particular for my cron scripts it seems that error messages get 
> wrapped up and emailed, but they are then out of context with the normal 
> informative output. If I could have the combined output go to my logs in 
> the normal way and detect that some error output had occurred I could 
> then email the whole cron output.
> 
> I'm fairly sure this is doable with some C, but is there an easier way?

Perhaps using redirects?

this can be used in /bin/sh (and thus cron):

./myprogram 2>&1

where "myprogram" is your application.
this would combine stderr and stdout.

-- 
Sten Daniel Soersdal


More information about the freebsd-questions mailing list