An error occurred while executing the shell script. syntax error: Unexpected "then" (expecting "}")

Source: Internet
Author: User
Tags rrd rrdtool

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.