Configure IP Based on HW Serial #

Hi,

I'm extremely green when it comes to Bash and Unix scripting, however I understand the language and flows but being so green to Linux i don't know the commands.

what i need to do is make an IF statement as follows:

If SERIAL# Equals 1234 IPADDRESS = 1.1.1.1 255.0.0.0 etc...

so far I've figured out that i can use the following command to get the HW serial #:

sudo /usr/sbin/dmidecode -t 1 | grep -e 'Serial Number' | cut -f 2

however i don't know how to set the output of this command as a variable.

any help with this would be greatly appreciated.

Try:

serial=`sudo /usr/sbin/dmidecode -t 1 | grep -e 'Serial Number' | cut -f 2`
if [ $serial=="1234" ]; then
  ifconfig eth0 inet 1.1.1.1/8
fi

bartus, that works wonderfully but when i execute it as a script it tells me

[root@localhost Desktop]# ./test
./test: line 2: [: Number:: binary operator expected

could it have something to do with the fact that the serial number contains letters too?