Wpisy oznaczone tagiem tee

bash parallel processing and error handling

Another note to myself.

Here is a way how I process some program execution which is sending xml to standard output.

This part of script executes, checks and compress program xml output in parallel.

Tested for output sizes > 10GB.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
$JAVA_HOME/bin/java -jar $jarFile \                                                                                                             
    | tee >(bzip2  > $archFile ) \                                                                                                          
    | (xmllint --stream --noout - )                                                                                                         
 
DUMPSTATUS=(${PIPESTATUS[*]})                                                                                                               
 
commandResult=${DUMPSTATUS[0]};                                                                                                         
bzipResult=${DUMPSTATUS[1]};                                                                                                                
checkResult=${DUMPSTATUS[2]};                                                                                                               
 
if [ "$commandResult" -ne 0 ]; then                                                                                                     
    die 'ERROR::could not execute command'                                                                                        
else                                                                                                                                        
    echo 'INFO::command successfully executed'                                                                                           
fi                                                                                                                                          
 
if [ "$checkResult" -ne 0 ]; then                                                                                                           
    die 'ERROR::xml is not correct'                                                                                                  
else                                                                                                                                        
    echo 'INFO::xml is correct'                                                                                         
fi                                                                                                                                          
 
if [ "$bzipResult" -ne 0 ]; then                                                                                                            
    die 'ERROR::could not create bzip file from output'                                                                                       
else                                                                                                                                        
    echo 'INFO::compression is successful'                                                                                             
fi

, , , , , , , ,

Brak komentarzy