marinux
Goto Top

Bash Escaping läuft nicht rund

Hallo,

ich benutze unter Debian6 die Standard-Shell: GNU bash, version 4.1.5

Dort habe ich folgendes Problem in einem Script, welches mit rrdtool eine Graphik erzeugen soll. In diesem Script soll dynamisch der Kommandozeilenaufruf dazu erweitert werden mit der Variablen $GRAPH

for i in ${!RRAs[*]}
do

GRAPH="${GRAPH}  DEF:${RRAs[$i]}=${LOG_PATH}/${CLIENT}_data.rrd:${RRAs[$i]}:AVERAGE"\  
" CDEF:${RRAs[$i]}_graph=${RRAs[$i]},8,*"\  
" AREA:${RRAs[$i]}_graph#edc24080:\"yyy Downstream\""  

done

        rrdtool graph ${IMAGE_PATH}/${CLIENT}.png\
         --end ${DATE_Ymd}\
         -t "xxx"\  
         -h 320\
         -w 1200\
         -a PNG\
         -v bit/s\
"$GRAPH"  


Das Problem dabei: Stelle ich $GRAPH mit doublequotes unter dem Kommandozeilenaufruf an, dann scheint meine komplette Übergabe als ein String interpretiert zu werden und rrdtool kann es nicht interpretieren. Siehe den Outptut mit bash -x:

rrdtool graph /var/log//xxx.png --end 20131214 -t 'xxx' -h 320 -w 1200 -a PNG -v bit/s  '  DEF:yyy=/var/log/xxx.rrd:yyy:AVERAGE CDEF:yyy_graph=yyy,8,* AREA:yyy_graph#edc24080:"yyy Downstream"' 

Stelle ich $GRAPH ohne quotes hinten an, dann bekomme ich:

rrdtool graph /var/log/xxx.png --end 20131214 -t 'xxx' -h 320 -w 1200 -a PNG -v bit/s DEF:yyy=/var/log/xxx.rrd:yyy:AVERAGE 'CDEF:yyy_graph=yyy,8,*' 'AREA:yyy_graph#edc24080:"yyy' 'Downstream"'  
ERROR: 'D' is not a valid function name  

Dabei scheint rrdtool den String "Downstream" als Argument zu verstehen, da es als extr String übergeben wird.

Wie mache ich es richtig?

Gruß

Marinux

Content-Key: 224439

Url: https://administrator.de/contentid/224439

Printed on: April 23, 2024 at 14:04 o'clock