How do l test for carriage return & Disk space usage

Hi,

I have just written a script in /bin/bash, however, l want to test if character is a carriage return or space. Also l want my script to be able to detect my disk space and send a mail if usage is more than 90% or send an alert.

Thanks

Kayode

bdf or df du give information about disk usage.
For example:

 bdf . | awk '{ if(NR==2){print $5}}' 

gives you the % free on the current disk.

'\015' is octal for ASCII 13 - carriage return.
You can use:

expr index $VAR '\015' 

to get the position of a carriage return (0=none found) in the variable VAR.

I use this:
UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`

if [$UsedSpace -ge 90 ]
select the files that you want to remove
rm -f selected files
fi

Thanx these scripts did work perfectly.

I need 2 scripts that will e-mail me if thressholds are exceeded.

One is for disk usage and one is for cpu usage. I got the df -k . one to work obviously for the file system I was in, but I'd like a command that would go through all of the file systems on all my servers and report back without having to hard-code the file systems.

Renae

Just capture the output of df -k (on Sun and Linux) or bdf (on HP) and carry out the check for each filesystem. A 'while do .. done' loop will do the job.

 bdf . | awk 'NR==2{print $5}'