Unix/Linux Go Back    


UNIX for Beginners Questions & Answers 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

UNIX for Beginners Questions & Answers


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-25-2018   -   Original Discussion by doghouse308
doghouse308's Unix or Linux Image
doghouse308 doghouse308 is offline
Registered User
 
Join Date: Feb 2018
Last Activity: 4 April 2018, 6:21 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old Unix and Linux 02-25-2018   -   Original Discussion by doghouse308
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 21 May 2018, 6:55 AM EDT
Location: Aachen, Germany
Posts: 12,716
Thanks: 412
Thanked 3,910 Times in 3,596 Posts
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.
Sponsored Links
    #3  
Old Unix and Linux 03-23-2018   -   Original Discussion by doghouse308
shajay12's Unix or Linux Image
shajay12 shajay12 is offline
Registered User
 
Join Date: Mar 2018
Last Activity: 30 March 2018, 12:14 AM EDT
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
what is $fsout ?? in 4th line, that is causing problem
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
c++ debugging gotenxds Programming 2 05-07-2012 02:09 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
Regarding Debugging sarwan Shell Programming and Scripting 2 02-09-2006 11:32 AM



All times are GMT -4. The time now is 04:37 PM.