terminal Crash and no root access

Asked by CARE on 2012-06-04

I am new here. What I did is that : I made a .sh script and move that script in /bin/bash. Now I am trying to open terminal but it disappear with an error /bin/bash : mail not found. Please help me out

#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
# set admin email so that you can get email
<email address hidden>"
# set alert level 90% is default
ALERT=25
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  #echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge $ALERT ]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail -s "Alert: Almost out of disk space $usep" $ADMIN
  fi
done

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Last query:
2012-06-04
Last reply:
2012-06-04
Wyatt Smith (wyatt-smith) said : #1

" I made a .sh script and move that script in /bin/bash" - I don't really know what you mean by this.

The script that you attached is a bourne shell script and not a bash script. The error "mail not found", may be due to the path environment variable not containing the mail command. You may want to try specifying the full path for the mail command.

/usr/bin/mail -s "Alert: Almost out of disk space $usep" $ADMIN

Can you help with this problem?

Provide an answer of your own, or ask CARE for more information if necessary.

To post a message you must log in.