Hi,

I am trying to convert grub hard drive definitions (as part of an installation 
script)

There a several issues. Below is a section of the code:
----------------------------------------------------------
echo "please enter the root partition drive ie; hda, hdb, sda,sda"
read DISK

if [ $DISK = "hda" ]
        then
        export GRUB=hd0
elif [ $DISK = "hdb" ]
        then
        export GRUB=hd1
elif  [ $DISK = "sda" ]
        then
        export X=2
        if [ -f /dev/hdb ]
        then
                $X = $X - 1
        fi

        export GRUB=hd$X
else
        export X=3
        if [ -f /dev/hdb ]
        then
                $X = $X - 1
        fi

        export GRUB=hd$X
fi

echo $GRUB
echo "please enter the partition number without the prefix ie; instead of hdb4, 
just type 4"
read PARTITION

$PARTITION = $PARTITION - 1              #line 130
export NODE = "$GRUB,$PARTITION"         #line 131
echo $NODE

----------------------------------------
when executed I recieve this output:
--------------------------------------------------------
please enter the root partition drive ie; hda, hdb, sda,sda
sda
hd2
please enter the partition number without the prefix ie; instead of hdb4, just 
type 4
3
./INSTALLATION: line 130: 3: command not found
./INSTALLATION: line 131: export: `=': not a valid identifier
./INSTALLATION: line 131: export: `hd2,3': not a valid identifier
--------------------------------------------------------------------
ERROR 1 - I suspect this has something to do with 'read' capturing the input 
value as a string rather than a number. I tried 'read' with the 'n' option but 
no avail.

ERROR 2 & 3 - I suspect this has something to do with the Unix quoting 
mechanisms. I tried nearly all combinations but still no cigar.

Any advice on how to solve these issues is appreciated.

Also if anyone knows a good reference on Arithmetic in Shell script please 
speak up. I am using 'Linux Programming 3rd Edition' Mathews and Stones (which 
is one thick book!) and there seems to be but a paragraph on aritmetic in bash.

Thanks in advance

Kevin Annies
 
 
--------------------------------------------------------

NOTICE

This message and any files transmitted with it is intended for the addressee 
only and may contain information that is confidential or privileged. 
Unauthorised use is strictly prohibited. If you are not the addressee, you 
should not read, copy, disclose or otherwise use this message, except for the 
purpose of delivery to the addressee. 

Any views or opinions expressed within this e-mail are those of the author and 
do not necessarily represent those of Coventry University.
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to