Quote:
Originally Posted by
panknil
Dear jagnikam,
ur code fine, but take care about the syntax of scripting
i have just corrected ur basic faults...
try it out
#!/bin/bash
Warning=90
df -h | sort -rn | awk '{print $5 " " $1 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $Warning ]
then
echo "Running out of space \"$partition ($usep%)\""
else
echo "This partition have enough space \"$partition ($usep%)\""
fi
done
and my one more suggestion is redirect the output if df -k in a file and the remove the first line of the file and then proceed...
ur current code is proceeding with the first line also which u dont need.
Regards,
Pankaj
thanks for reply
I got this output after executing script provided by U. actually i am using NFS & some drive mounted on my HDD. this creating problem for me .
This partition have enough space "192.168.0.2:/usr (38%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/nodes/192.168.0.106/var: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/nodes/192.168.0.106/var%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/nodes/192.168.0.106/etc: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/nodes/192.168.0.106/etc%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/node_root: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/node_root%)"
./test1.sh: line 7: [: 192.168.0.15:/var/spool/mail: integer expression expected
This partition have enough space " (192.168.0.15:/var/spool/mail%)"
./test1.sh: line 7: [: 192.168.0.15:/tftpboot/node_root/var/lib/dpkg: integer expression expected
This partition have enough space " (192.168.0.15:/tftpboot/node_root/var/lib/dpkg%)"
./test1.sh: line 7: [: 192.168.0.15:/neuralit/work: integer expression expected
This partition have enough space " (192.168.0.15:/neuralit/work%)"
./test1.sh: line 7: [: /home: integer expression expected
This partition have enough space "110G (/home%)"
./test1.sh: line 7: [: /var/lib/dpkg: integer expression expected
This partition have enough space "65G (/var/lib/dpkg%)"
./test1.sh: line 7: [: /var: integer expression expected
This partition have enough space "65G (/var%)"
./test1.sh: line 7: [: /etc: integer expression expected
This partition have enough space "65G (/etc%)"
./test1.sh: line 7: [: /: integer expression expected
This partition have enough space "65G (/%)"
./test1.sh: line 7: [: /var/spool/mail: integer expression expected
This partition have enough space "6.0G (/var/spool/mail%)"
This partition have enough space "varrun (1%)"
This partition have enough space "varlock (1%)"
This partition have enough space "tmpfs (1%)"
This partition have enough space "tmpfs (0%)"
This partition have enough space "tmpfs (0%)"
This partition have enough space "none (1%)"
./test1.sh: line 7: [: Use: integer expression expected
This partition have enough space "Filesystem (Use%)"
This partition have enough space "devshm (0%)"
Please Help me
Tanks & Regards
Jagannath Nikam