Home Man
Search
Today's Posts
Register

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Debugging Help needed

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 02-25-2018
Debugging Help needed

I am VERY much a neophyte with shell scripting. I am working on the following,

"Create a script sends an email message to the user specified on the command line if any of the file
systems at more than 60% of capacity. The script should not process special file systems as /proc on
the ce.uml.edu. It should only process file systems which are either locally mounted or are mounted
via NFS."

This is my starting point:

Code:
#!/bin/bash
#  script to send an email message to the user specified on the command line if
# any of the file systems at more than 60% of capacity.

df -H | grep -vE '^Filesystem' | 'none' | awk '{ print $1 " " $5 }' | while read fsout
do
  echo "$fsout"
  partition=$(echo "$fsout" | awk '{ print $2 }' )
  usage=$(echo "$fsout" | awk '{ print $1 }' | cut -d'%' -f1)

  if [ $usage -ge 90 ]
  then
    echo "CRITICAL WARNING!!: Filesystem \"$partition\" at "$usage"% of capacity" |
    mail -s "CRITICAL WARNING!!: Filesystem \"$partition\" at "$usage"% of capacity" paul_peterson@student.uml.edu

  elif [ $usage -ge 60 ] && [ $usage -lt 90 ]
  then
    echo "Warning!!: Filesystem \"$partition\" at "$usage"% of capacity" |
    mail -s "Warning!!: Filesystem \"$partition\" at "$usage"% of capacity" paul_peterson@student.uml.edu
  fi
done

I ma getting these errors:

Code:
./fsc.sh: line 4: $'\r': command not found
./fsc.sh: line 16: syntax error near unexpected token `elif'
'/fsc.sh: line 16: `  elif [ $usage -ge 60 ] && [ $usage -lt 90 ]

Any help is greatly appreciated.


Moderator's Comments:
Debugging Help needed Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-25-2018 at 12:17 PM.. Reason: Added CODE tags.
# 2  
Old 02-25-2018
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
# 3  
Old 03-23-2018
what is $fsout ?? in 4th line, that is causing problem
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Debugging Help Needed doghouse308 Homework & Coursework Questions 7 02-28-2018 03:33 PM
c++ debugging gotenxds Programming 2 05-07-2012 02:09 PM
Debugging csh scripts!? vas28r13 Shell Programming and Scripting 0 07-20-2011 05:12 PM
Fixer Debugging erzal Homework & Coursework Questions 0 10-29-2010 06:40 AM
debugging satish@123 Solaris 0 06-17-2008 10:16 AM
debugging in bash!!! help needed wrapster Shell Programming and Scripting 2 02-25-2008 07:44 AM
Debugging a c/c++ program bogarams UNIX for Advanced & Expert Users 3 05-14-2006 07:19 PM
Regarding Debugging sarwan Shell Programming and Scripting 2 02-09-2006 11:32 AM


All times are GMT -4. The time now is 05:43 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password