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:

  1. when scalaprog fails, pipe stderr third program
  2. handling ioerror: [errno 32] broken pipe in 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -