Debugging Help needed

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Debugging Help needed
# 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:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-25-2018 at 01: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 or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Debugging Help Needed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! I am VERY much a neophyte with shell scripting. I am working on the following, 1. The problem statement, all variables and given/known data: "Create a script sends an... (7 Replies)
Discussion started by: doghouse308
7 Replies

2. Shell Programming and Scripting

Debugging functions

So here I have a simple function that I wish to debug. However, I am unable to debug the desired function even with set -o functrace enabled. Before resorting to asking this question, I had managed to find a possible solution that did not produce the desired results, which is located here. How... (5 Replies)
Discussion started by: BrandonD
5 Replies

3. Programming

c++ debugging

hey i have a problem with a switch case in program and the debugger is messy has hell ( we use normal VI and gdb in our schoool to make it more diffiacult) any way i have a problom where for some unknown reason the debugger just skips a switch statment as if it wasent even there the rest... (2 Replies)
Discussion started by: gotenxds
2 Replies

4. Shell Programming and Scripting

script debugging

is there any way you can add a breakpoint in a script so you can stop on it? i have used -xv in my shebang but the script just runs and i want it to stop at a specific point in the script. appreciate any help. (1 Reply)
Discussion started by: npatwardhan
1 Replies

5. Programming

Need some help in debugging the C-Progam.

Hi i want to debug the C program with GDB debugger. I want to debug the program by line by line. I want to debug program like as we debug the program in Turbo-C using the F8. Can any one help me? I know i have to use single stepping. But i don't know how to use it. Any help can be appreciated..... (5 Replies)
Discussion started by: ps_sach
5 Replies

6. Solaris

debugging

when I tried to debug my application i got the following. gdb -v GNU gdb 6.6 file is in C and Xmotiff Languages (gdb) attach 25499 Attaching to process 25499 Retry #1: Retry #2: Retry #3: Retry #4: 0xfea40b68 in ?? () (gdb) where #0 0xfea40b68 in ?? () (0 Replies)
Discussion started by: satish@123
0 Replies

7. Shell Programming and Scripting

debugging in bash!!! help needed

Hi all, Am using bash shell. Am newbie, trying to understand the debugin process of a shell script... I am unable to comprehend the control flow ,meaning from where exactly the execution of the script begins... I tried using bash-xv <scriptname> but since am new ,am finding it difficult to... (2 Replies)
Discussion started by: wrapster
2 Replies

8. Programming

Semaphore debugging

I'm running one multithreaded application, in that one of my thread is waiting infinitely in a semphore. Is there a way to determine, in which semaphore the particular thread is waiting and which thread(s) is holding the semaphore. (5 Replies)
Discussion started by: ptprabu
5 Replies

9. Programming

function debugging. help

Hi, I tried creating my version of the cat function in bash but left it and now I'm trying to make this function work, but it wouldn't. #include <sys/param.h> #include <sys/stat.h> #include <locale.h> #include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h>... (2 Replies)
Discussion started by: sanchopansa
2 Replies

10. Shell Programming and Scripting

Regarding Debugging

Hi, If we want to debug a shell script, then set -vx has to be included in the begining of the script. Just i want to know what purpose -vx is used. Thanks in advace Sarwan (2 Replies)
Discussion started by: sarwan
2 Replies
Login or Register to Ask a Question