python - How to make sure errors in pipes get reported -
i
python py_prog.py | java scalaprog.pkg the python program must fetch stuff db , pipe scala program. have centralized error monitoring python scala program may silently fail. if scala program fails, want stderr transferred our monitoring system third program bash pseudocode:
(python py_prog.py | java scalaprog.pkg) || python logging_program.py (writing logging_program , making talk our error monitoring easy, setting similar system scala program hard).
so how accomplish:
- when scalaprog fails, pipe stderr third program
- handling
ioerror: [errno 32] broken pipein py_prog when scalaprog fails
with bash use process subtitution , still see output of java scalaprog.pkg:
python py_prog.py | java scalaprog.pkg 2> >(python logging_program.py) or place on tee see stderr on terminal well:
python py_prog.py | java scalaprog.pkg 2> >(tee >(python logging_program.py)) if it's shell runs java scalaprog.pkg sends error message encapsulate in subshell error well:
python py_prog.py | (java scalaprog.pkg;) 2> >(tee >(python logging_program.py)) if need (both stdout , stderr java scalaprog.pkg this:
python py_prog.py | java scalaprog.pkg > >(tee >(python logging_program.py)) 2>&1 or this:
python py_prog.py | (java scalaprog.pkg;) > >(tee >(python logging_program.py)) 2>&1 if want stdout , stderr both python py_prog.py , java scalaprog.pkg this:
{python py_prog.py | java scalaprog.pkg;} > >(tee >(python logging_program.py)) 2>&1 or includes error might generated calling shell well:
(python py_prog.py | java scalaprog.pkg;) > >(tee >(python logging_program.py)) 2>&1 if want stderr session use 2>:
(python py_prog.py | java scalaprog.pkg;) 2> >(tee >(python logging_program.py))
Comments
Post a Comment