syntax error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax error
# 1  
Old 08-15-2007
syntax error

A newbie in scripting is trying to run the script bellow but keep getting an error message ;

syntax error at line 76 : `<<' unmatched

what we have on that area pointed to is highlighted in red bellow:
##################################################
fi
# Memory Performance (vmstat - sr column)
# The experts say that when the 'sr' or scan rate column reaches above #200,
# the system is scanning through memory looking for pages to free at a #high
# rate. This indicates active pages might be stolen from processes. A high
# scan rate can cause your system to consume more cpu resources than it
# normally would.

MEMSTAT=`echo $VMDAT | tail -1 | awk '{ print $12 }'`

if [ "$MEMSTAT" -gt "200" ]; then
mail $MAILADD <<EOF

From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load.
EOF
################################################

can u guys see to this?
# 2  
Old 08-15-2007
<<EOF has to be matched with EOF in column1 at the end of the here document (what a <<EOF ..... EOF block delimits)

example:
Code:
/path/to/some_program_that_needs_input <<EOF
YES
NO
SEP-05-2007
EOF

The stuff between the EOF's behaves as if those were answers to prompts, or is information that is read into stdin.
# 3  
Old 08-16-2007
Re syntax error- still not working

jim and all,

i think in my own dummy way that the satisfy the code example stated bellow by jim mcnamara. I am a bit confused because the same format was used for others. for clearity purpose i hereby copy the whole scripts for you the forum to help me debug and tell me what is wrong.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Code:
#!/bin/ksh
#
# Solaris 2.X Performance Monitoring Script
# Purpose: This script executes performance commands and notifies via
# e-mail when performance is poor.
# Useage: Execute the script from crontab at 30 minute intervals.
# Dependencies: None
# Outputs: Logfiles and e-mail
# CRONTAB EXAMPLE (Mon - Fri 7am - 6pm):
# 17,47 7-18 * * 1-5 /opt/admin/scripts/mon_prf.sh
#
#**************************************************************************
PATH=$PATH:/usr/sbin:/usr/bin

# Define the server's hostname
SRVNM=`uname -n`

# The directory this script resides in
ADMINDIR=/opt/admin/scripts

# Create log directory
DATDIR=/var/adm/log/mon_perf
if [ !  -d $DATDIR ] ; then
     mkdir -p $DATDIR
fi

# The next variable can be set for multiple addresses
MAILADD=tunji.salami@anglia.ac.uk

# vmstat  VMDAT=`vmstat 1 2 | tail -1`
# CPU Performance (vmstat - r column)
# When the 'r' or run queue column reaches above 3 processes per CPU,
# there is insufficient CPU power, and jobs are spending an
# increasing amount of time in the queue before being assigned to a CPU.
# This reduces throughput and increases interactive response time.


CPUPERF=`echo $VMDAT | awk '{ print $1 }'`
if [ "$CPUPERF" -gt "3" ]; then
 mail $MAILADD <<EOF

From:$SRVNM
To: $MAILADD
Subject: CPU Performance on $SRVNM
The vmstat run queue column has exceeded 3 processes per CPU on $SRVNM. There is                                              insufficient CPU power for the load placed

on  the server.
EOF

fi
# CPU Performance (vmstat - cpu id column)
# The cpu id column indicates what % the cpu is idle

CPUSTAT=`echo $VMDAT | awk '{ print $22 }`
if [ "$CPUSTAT" -lt "10" ]; then
    mail $MAILADD <<EOF

From:$SRVNM
To: $MAILADD
Subject: CPU Performance on $SRVNM
The vmstat cpu id column is less than 10 on $SRVNM.
The CPU is idle $CPUSTAT % of the time.
EOF

fi
# Memory Performance (vmstat - sr column)
# The experts say that when the 'sr' or scan rate column reaches above 200,
# the system is scanning through memory looking for pages to free at a high
# rate. This indicates active pages might be stolen from processes. A high
# scan rate can cause your system to consume more cpu resources than it
# normally would.

MEMSTAT=`echo $VMDAT | tail -1 | awk '{ print $12 }'`

if [ "$MEMSTAT" -gt "200" ]; then
    mail $MAILADD <<EOF

From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load.
EOF

fi
# TCP Connections
#  TCPCON=`netstat -aP tcp | tail +39 | wc -l`
 if [ "$TCPCON" -gt "900" ]; then
 mail $MAILADD <<EOF

From:$SRVNM
To: $MAILADD
Subject: TCP Connections on $SRVNM
According to netstat -a, there are currently $TCPCON
TCP connections on $SRVNM. This may or may not be  cause for concern.

EOF

fi

# NIC Input Errors
#

# netstat -i
#NETIDAT=`netstat -i | grep ce0`

#NICIE=`echo $NETIDAT | awk {'print $6'}`
#    if [ "$NICIE" -gt "10" ]; then
#           mail $MAILADD <<EOF

#From:$SRVNM
#To: $MAILADD
#Subject: NIC Input Errors on $SRVNM
#According to netstat -i, there are currently $NICIE
#input errors on $SRVNM ce0 NIC.

#EOF

#fi

# NIC Output Errors
#
#NICOE=`echo $NETIDAT | awk {'print $8'}`
#    if [ "$NICOE" -gt "10" ]; then
#           mail $MAILADD <<EOF
#From: $SRVNM
#To: $MAILADD
#Subject: NIC Output Errors on $SRVNM
#According to netstat -i, there are currently $NICOE
#output errors on $SRVNM ce0 NIC.
#EOF
#fi
# iostat
# Disk performance
# Create iostat data file
#DATFILE=$DATDIR/iostat.dat
#cp $DATFILE $DATFILE.old
#cp /dev/null $DATFILE
# Checking the iostat util column
#IODAT=`iostat -Dl 20 -n | tail -1`

#DSKSTAT=`echo $IODAT | awk '{ print $3, $6, $9, $12, $15, $18, $21, $24, $27, $                                             30, $33, $36, $39, $42, $45, $48, $51, $54,

$57, $60 }'`
# Will need to edit the next line to resolve this problem
#echo $DSKSTAT >> $DATFILE
#cat iostat.dat | awk {'print $2'}

#while read -r
#do
#        if [ "$REPLY" -gt "3" ]; then
#           mail $MAILADD <<EOF

#From: $SRVNM
#To: $MAILADD
#Subject: Disk Performance on $SRVNM
#According to iostat, the disk utilization on $SRVNM is
#greater than 3 on one of the server's hard disks. This
#indicates that the disk is being heavily used.
#EOF
#fi
#done < $DATFILE

# netstat

# CPU Data
#mpstat

# swap
#swap -l

# /tmp (Running out of swap space)
# du -sk /tmp

exit 0

#


Last edited by vino; 08-16-2007 at 05:04 AM.. Reason: Fixed code tags
# 4  
Old 08-17-2007
waitng for an answer

can someone look at this for me pleeeaseeee
# 5  
Old 08-17-2007
you missed a quote:

Quote:
Originally Posted by ibroxy
jim and all,

i think in my own dummy way that the satisfy the code example stated bellow by jim mcnamara. I am a bit confused because the same format was used for others. for clearity purpose i hereby copy the whole scripts for you the forum to help me debug and tell me what is wrong.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Code:
#!/bin/ksh
#.......


.
.
# CPU Performance (vmstat - cpu id column)
# The cpu id column indicates what % the cpu is idle

CPUSTAT=`echo $VMDAT | awk '{ print $22 }'`
if [ "$CPUSTAT" -lt "10" ]; then
    mail $MAILADD <<EOF

# 6  
Old 01-03-2008
try this

Not sure but try following :

if [ "$MEMSTAT" -gt "200" ]; then
mail $MAILADD <<EOF
echo "
From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load. "
EOF

Let know how it goes. Atleast if you get another error, we can resolve the problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting this error syntax error near unexpected token `)'

Hi Everyone, my script was running Ok, but suddenly it started giving this error. ./update_env_bi.sh: line 54: syntax error near unexpected token `)' ./update_env_bi.sh: line 54: `sed -i "s/PORT=*1/PORT=$2/" repository.xml' The line 54 has this code. sed -i "s/PORT=*1/PORT=$2/"... (2 Replies)
Discussion started by: shajay12
2 Replies

2. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

3. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

4. Shell Programming and Scripting

Receiving error: ./ang.ksh[35]: 0403-057 Syntax error at line 116 : `done' is not expected.

Hi All I am quite new to Unix. Following is a shell script that i have written and getting the subject mentioned error. #!/bin/ksh #------------------------------------------------------------------------- # File: ang_stdnld.ksh # # Desc: UNIX shell script to extract Store information.... (3 Replies)
Discussion started by: amitsinha
3 Replies

5. Shell Programming and Scripting

ERROR: ./launch_full_backup.sh[18]: Syntax error at line 28 : `else' is not expected.

Help please! :confused: I have the following error with the following file and the emails are not arriving to the email, any idea please? ERROR: ./launch_full_backup.sh: Syntax error at line 28 : `else' is not expected. FECHA=`date +%d%m%y%H%M`... (2 Replies)
Discussion started by: villenan
2 Replies

6. Programming

Newbie Question.. -> error: syntax error before ';' token

Hello, the following is generating a error at the line "tmprintf(&tmBundle, _TMC("{0}"),Prompt);"... a bit lost as I am diving into this debug... Thank you in advance... int H_YesNo(TMCHAR *Prompt, int DefVal) { TMCHAR YesNo = '\0'; tmprintf(&tmBundle, _TMC("{0}"),Prompt); while... (3 Replies)
Discussion started by: reelflytime
3 Replies

7. Shell Programming and Scripting

sed error : Syntax error: redirection unexpected

My script is throwing the error 'Syntax error: redirection unexpected' My line of code.. cat nsstatustest.html | sed s/<tr><td align="left">/<tr><td align="left" bgcolor="#000000"><font color="white">/ > ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3 HTML tags are getting in the way but they're needed to... (3 Replies)
Discussion started by: phpfreak
3 Replies

8. AIX

nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error

-------------------------------------------------------------------------------- Hello, help me please. I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? : Command : failed stdout: yes stderr: no... (9 Replies)
Discussion started by: astjen
9 Replies

9. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies
Login or Register to Ask a Question