Configure IP Based on HW Serial #


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Special Forums IP Networking Configure IP Based on HW Serial #
# 1  
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:

Code:
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 #:

Code:
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.
# 2  
Try:
Code:
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

# 3  
Quote:
Originally Posted by bartus11
Try:
Code:
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

Code:
[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?
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #751
Difficulty: Medium
The first IBM 5150 PCs had two 5.25-inch 360 KB single sided double density (SSDD) floppy disk drives
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

2. Solaris

Can we configure link based IPMP in private connectivity in Oracle RAC

Hi I would like to know whether we can configure link based IPMP in private connectivity in Oracle RAC Regarsd ---------- Post updated at 04:35 PM ---------- Previous update was at 04:27 PM ---------- Here I am taking about in case of private connectivity through cross cable (6 Replies)
Discussion started by: sb200
6 Replies

3. HP-UX

Help with serial ports.

Hi, This is my first post here. I would like to ask: how to connect the barcode scanner to the serial port? What are the names in the system (in / dev) and serialport1 serialport0? Please help with this. Regards. (2 Replies)
Discussion started by: ftwojtek
2 Replies

4. UNIX for Advanced & Expert Users

Transition from Windows-based network to Linux-based

I am looking to make the switch from a Windows based network to a Linux (preferably Ubuntu, because I used it the most) based one. Currently the network includes a Windows 2003 server which acts as a domain controller and file server, a network shared printer (Canon 2300N) and 7 clients running... (2 Replies)
Discussion started by: larynx
2 Replies

5. Shell Programming and Scripting

How to fetch rows based on line numbers or based on the beginning of a word?

I have a file which will have rows like shown below, ST*820*316054716 RMR*IV*11333331009*PO*40.31 REF*IV*22234441009*xsss471-2762 DTM*003*091016 ENT*000006 RMR*IV*2222234444*PO*239.91 REF*IV*1234445451009*LJhjlkhkj471-2762 </SPAN> DTM*003* 091016 RMR*IV*2223344441009*PO*40.31... (18 Replies)
Discussion started by: Muthuraj K
18 Replies

6. Ubuntu

Ubuntu 9.04 Serial application to telnet to serial device

Hello! I am working on an application which reads environmental instruments which have serial ports. The application requires a serial port to be present to talk to the device (i.e. /dev/ttyS0 ). In some instances the environmental devices will be 100's of yards away from the computer, so a... (5 Replies)
Discussion started by: mvona
5 Replies

7. Programming

What is the difference between console-based and xwindow-based application?

Hi everyone, What is the difference between console-based and Xwindow-based application? Can I say the application working well in Xwindows can work in console? Can I say the application working well in console cann't work in Xwindow perhaps. Eg, ncurses is console-based and Imlib2 is... (4 Replies)
Discussion started by: liuyan03
4 Replies

8. Solaris

Serial number

Hi Solarizer ;) I have face the difficulties of gathering information about the serial number of sun machine. i think its can do so easy while the machine is just one or two. But i have to administrate hundreds of sun machine. Any body knows how to gather this information by the command ? ... (4 Replies)
Discussion started by: tpx99
4 Replies

9. IP Networking

TCP over serial

Here's my config: One quadra 840av working under netBSD and successfully connected to my network. One PM 6100 connected but not booting fully into netBSD (i realize this is faulty but I figured it was worth a shot to try and install netBSD/mac68k on it due to the fact it is unsupported under the... (1 Reply)
Discussion started by: Yummator
1 Replies

10. UNIX for Dummies Questions & Answers

serial communication

This isn't really a unix question, or even a programming question, but I hope you guys can help. I want to create a program to control the electricity on a model railway. I have created the program to that it sends characters over the serial cable, but now I need to do the switch that will... (1 Reply)
Discussion started by: KrazyGuyPaul
1 Replies

Featured Tech Videos