简体   繁体   中英

RRD works not from shell script

I am using this code to create a graph with the the RRD:

#!/bin/sh
rrdtool graph tempweek.png \
-s "now - 1 day" -e "now" \
DEF:temp0=temperature.rrd:temp0:AVERAGE \
LINE2:temp0#33E500:Außen \
DEF:temp1=temperature.rrd:temp1:AVERAGE \
LINE2:temp1#FF6600:Pool \
DEF:temp2=temperature.rrd:temp2:AVERAGE \
LINE2:temp2#0066CC:Dach

When I insert the command in the console all works finde but when I run it via a shell script I got an error.

在此处输入图片说明

My guess is that you used a windows editor to write your script ... it inserts CRLF between lines instead of just LF as it is the norm in Unixland.

This little perl one-liner ...

perl -I~ -pe 's/\r\n/\n/g' rrd.sh

will fix your script. Run it on the command line.

To stop this from happening in the future make sure to set your editor to write files with LF line endings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM