disk space utilization script

Hi,

I wrote the following script for monitoring disk space and inform the concerned team accordingly. But script gives me below error

syntax error at line 70 : `<' unmatched
#!/bin/ksh


. /home/scr/.profile

. /home/scr/.infa_env


# Get the list of Integration Services

infacmd.sh listservices -dn $INFA_DOMAIN -un Administrator -st IS | sed '$d' > $scripts_path/temp_ds.txt

while read line

   do

   ISDir=$(grep $line < $scripts_path/integration_services.txt | awk '{print$2}')

   echo "Integration Service path:"$ISDir


   disk_limit=$(grep $line < $scripts_path/integration_services.txt | awk '{print$3}')

   echo " "
   echo "Defined threshold limit for file system of data directory ${ISDir} is ${disk_limit}."
   echo " "

df -k ${ISDir}
        total_disk=`df -k ${data_dir}|tail -1|tr -s ' ' ' '|cut -f2 -d " "`;export total_disk
        available_disk=`df -k ${data_dir}|tail -1|tr -s ' ' ' '|cut -f3 -d " "`;export available_disk
        disk_percent_used=`df -k ${data_dir}|tail -1|tr -s ' ' ' '|cut -f4 -d " "`;export disk_percent_used
        used_disk=`expr ${total_disk} - ${available_disk}`
        mounted_file_system=`df -k ${data_dir}|tail -1|tr -s ' ' ' '|cut -f7 -d " "`;export mounted_file_system

        if [ ${used_disk} -ge ${disk_limit} ];
           then
                echo " "
                echo "WARNING:"
                echo "Available disk space of file system ${mounted_file_system} for Integration Service directory ${ISDir}"
                echo "is ${used_disk} Kbytes which is greater than the defined threshold limit of ${disk_limit} Kbytes."
                echo " "
                echo "Please increase size of file system ${mounted_file_system} for PowerCenter Integration Service Directory ${ISDir} before"
                echo "Informatica file system runs out disk space otherwise Informatica PowerCenter operations may be compromised."

        #Notification module
                mailx -s "Email notification of Integration Service direcroty exceeding 				defined threshold" ${alertlist} <<-!
                                WARNING: ${ISDir} filesystem has exceeded their upper 				limit.
                                Available disk space of file system 				${mounted_file_system}
                                for data directory ${ISDir} is ${available_disk} Kbytes
                                which is greater than the defined threshold limit of
                                ${disk_limit} Kbytes.

                                Please increase size of file system 				${mounted_file_system}
                                or Integration Service directory before the file
                                system runs out disk space otherwise PowerCenter 901 						operations may be compromised.
                                !

        echo " "
        echo "Note:  Email notification of Integration Service direcroty exceeding 	defined threshold"
        echo "was sent to ${alertlist}"

        fi

    done < $scripts_path/temp_ds.txt

    rm $scripts_path/temp_ds.txt

Please let me know the issue.

Sam

What's your input file look like? Does this happen on every line of input?

Hi,

My input file (integration_services.txt) look like this:

Intg_Svc01 /d1/Intg_Svc01 83886080
Intg_Svc02 /d2/Intg_Svc02 167772160
Intg_Svc03 /d3/Intg_Svc03 83886080
Intg_Svc04 /d4/Intg_Svc04 83886080

Yes it greps for each line of input and get the value in 2nd and 3rd column from above file.

Sam

Likely to be due to this line:

The "!" at the end of your "here" document MUST be in column one. Is is indented in error.

More precisely, that '!' must be either in column one or preceded by tabs in your script. There are likely some spaces characters instead of tabs before the '!'.

The ending string must start in column one when <<string is used, <<-string allows indentation.

Btw. If I run in validation only mode with "ksh -n" my error message is:

syntax error at line 46 : `<<' unmatched

No idea where the posted error came from.

Well spotted jlliagre .
The error is indeed cleared by removing all spaces from the line containing the terminating "!" line or replacing those spaces with one or more tabs.

Thanks everyone. I have actually changed the mailx command. I gave something like this and it worked.

echo "email body" | mailx -s "Email notification of Integration Service direcroty exceeding defined threshold" ${alertlist}