weird output
Please support our Shell Scripting advertiser: Programming Forums
Thread Solved
![]() |
•
•
Posts: 210
Reputation:
Solved Threads: 0
I had a similar script in solaris and it had no problem. I wrote this one in freeBSD and it gave me strange output. Can anyone please tell me why? thanks a lot
output:
#!/bin/sh
#This is a shell script that checks file system capacity mounted on /home directory
#If file system is over 90% capacity, this shell script will generate notification emails sending to all users
warning()
{
fs=$1 # first argument is the file system name
fscap=$2 # second argument is the file system's capacity
for user in `ls /home`
do
echo "File system mounted on /home directory is over 90% capacity. Please be ready for system maintainance. " | mail -s "Warning! $fs here is at $fscap capacity" user
done
echo "Warning: $fs is at $fscap capacity"
}
daOslg= `df -h | sed -n '/home/p' | tr -s ' ' ' ' | cut -d' ' -f1`
daOslgCap= `df -h | sed -n '/home/p' | tr -s ' ' ' ' | cut -d' ' -f5`
if ["$daOslgCap" -gt "90%"]
then
warning $daOslg $daOslgCap
fioutput:
$ ./capChecker ./capChecker: /dev/da0s1g: Permission denied 0%: not found [: missing ]
•
•
Posts: 399
Reputation:
Solved Threads: 47
Hey there,
I think definitely you'll see some differences in performance. Solaris' sh is the bourne shell and a lot of linux/bsd distro's just like sh to bash or another shell.
The one thing I saw that jumped out at me was:
if ["$daOslgCap" -gt "90%"]
there may be 2 issues with this. Try padding spaces in between the [] and, possibly, check and see if there's an issue with the sense of your "if check", since "90%" is an alpha value and -gt is a unary comparison operator.
to add the spaces:
for the other part, you should clip the % from your value so you'll be checking if
Hope that helps you get closer to an answer, if it doesn't answer the whole thing. If you could post the output of :
that might shed some more light.
Best wishes,
Mike
I think definitely you'll see some differences in performance. Solaris' sh is the bourne shell and a lot of linux/bsd distro's just like sh to bash or another shell.
The one thing I saw that jumped out at me was:
if ["$daOslgCap" -gt "90%"]
there may be 2 issues with this. Try padding spaces in between the [] and, possibly, check and see if there's an issue with the sense of your "if check", since "90%" is an alpha value and -gt is a unary comparison operator.
to add the spaces:
•
•
•
•
if [ "$daOslgCap" -gt "90%" ]
for the other part, you should clip the % from your value so you'll be checking if
•
•
•
•
$daOslgCap -gt 90
Hope that helps you get closer to an answer, if it doesn't answer the whole thing. If you could post the output of :
•
•
•
•
/bin/sh -x capChecker
that might shed some more light.
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Similar Threads
Other Threads in the Shell Scripting Forum
- Char array, getting weird output (C++)
- C++ question(Decimal places)very weird (C++)
- bubble sorting in an array (C)
- Computer on, but no video output (Windows NT / 2000 / XP / 2003)
- Weird segfault involving popen (C)
- MERGED: Deleting duplicates in an array (plz help me out!!!!!!!) (C)
Other Threads in the Shell Scripting Forum
- Previous Thread: opening multiples files in awk?
- Next Thread: Anyone know anything about WINBATCH?
•
•
•
•
Views: 499 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode