This script works perfectly on my main computer but,
I tried it on other computers with only one partition
and instead of listing /dev/hda2 as "0" , it pops these error messages.
The error messages don't effect the math so I would like to make them gone.
I can get rid of the first message.....
/dev/hda2: No such device or address
with this...
a=`/sbin/sfdisk -s $i 2> /dev/null`
I just don't know how to get rid of the second message.
./drive: line 39: / 1024: syntax error: operand expected (error token is "/ 1024")
Any ideas????
Code:
drive=`/sbin/sfdisk -s $1`
echo
for i in `/sbin/sfdisk -l $1 | \
grep -e "^[/dev]" | awk '{print $1}'`;
do
a=`/sbin/sfdisk -s $i`
part=$(($a / 1024))
totalused=$(($totalused + $a))
echo "Partition $i used $part MB"
done
[root@sony home]# ./drive /dev/hda
Partition /dev/hda1 used 10040 MB
/dev/hda2: No such device or address <<<<<<<<<<<<
sfdisk: cannot open /dev/hda2 for reading
./drive: line 39: / 1024: syntax error: operand expected (error token is "/ 1024") <<<<<<<<<
Total drive size 25941 MB
Partitioned size 10040 MB
Unpartitioned size 15901 MB
Code:
drive=`/sbin/sfdisk -s $1`
echo
for i in `/sbin/sfdisk -l $1 | \
grep -e "^[/dev]" | awk '{print $1}'`;
do
a=`/sbin/sfdisk -s $i 2> /dev/null`
part=$(($a / 1024))
totalused=$(($totalused + $a))
echo "Partition $i used $part MB"
done
[root@sony home]# ./drive /dev/hda
Partition /dev/hda1 used 10040 MB
./drive: line 38: / 1024: syntax error: operand expected (error token is "/ 1024") <<<<<<<<
Total drive size 25941 MB
Partitioned size 10040 MB
Unpartitioned size 15901 MB