An error occurred while executing the script today, such:
root@ApFree:/usr/sbin# ./conntrack_num_graph.sh ./conntrack_num_graph.sh: line 9: syntax error: unexpected "then" (expecting "}")root@ApFree:/usr/sbin#
I am wondering, this script can be executed normally a few days ago. Why is an error occurring today? Why?
The cat script is as follows:
#! /Bin/shsitename = "apfree" listening # change for your sitemkdir-P/mnt/RRD # iptables-l traffic-vnxz-T filter>/tmp/traffic. TMP #$1 = imagefile, $2 = Time in secs to go back, $3 = rrdfile, $4 = graphtextcreategraph () {listening and listening # only run, if no other rrdtool is running, you can hear it. If [-n "$ (PS | grep rrdtool | grep-V grep)"]; then return listen fi listen rrdtool graph "$ {1}"-a PNG-S-"$ {2 }" -W 550-H 240-V "" \ Listen to listen to hear 'def: Count = '$ {3}': conntrack_count: average '\ listening/listening area: Count #32cd32: conntrack number '\ listener: 0 #000000 '-T "$ {4}"} Listen # Build sum-grapffe [! -E/mnt/RRD/conntrack_num.rrd]; then: Listen. rrdtool create/mnt/RRD/conntrack_num.rrd-S 300 \ Listen. DS: conntrack_count: gauge: 600: 0: 600000000 \ listening/listening RRA: average: 0.5: 1: 600ficonntrack_count = 'cat/proc/sys/NET/Netfilter/nf_conntrack_count 'rrdtool update/mnt/RRD/conntrack_num.rrd N: $ conntrack_countcreategraph/mnt/RRD/conntrack_num.png 86400/mnt/RRD/conntrack_num.rrd "conntrack from $ sitename"
Nima, now I understand that there is a garbled code! No wonder an error occurs!
Why are there garbled characters? Oh, it turns out that I deleted the script and copied the Code directly from the MACO notepad to recreate the script!
Solution: delete all the garbled characters and execute the code again. It's okay, but this is really troublesome. If you have a more convenient way, please let me know.