Visit Our UNIX and Linux User Community


Cisco Mac Question


 
Thread Tools Search this Thread
Operating Systems Solaris Cisco Mac Question
# 1  
Old 04-09-2009
Cisco Mac Question

When I do a snmpwalk of my router the mac address are not what I expected.

Then return looking like this
Quote:
0:1c:c9:2a:b6:77
How would you convert them to 001c.c92a.b677 when a shell script?
# 2  
Old 04-09-2009
Awful long but works:
Code:
echo "0:1c:c9:2a:b6:77"| tr -s ':' '\n'|  sed 's/^.$/0&/'| tr -d '\n'| sed 's/\(....\)\(....\)\(....\)/\1\.\2\.\3\n/g'
001c.c92a.b677

# 3  
Old 04-09-2009
Here is a pure shell solution using ksh93
Code:
#!/usr/bin/ksh93

MAC="0:1c:c9:2a:b6:77"

IFS=":" typeset -a array=($MAC)

outmac=""
for ((i = 0; i < 6; i++))
do
   (( ${#array[i]} < 2 )) && outmac="${outmac}0"
   outmac="${outmac}${array[i]}"
   (( i < 5 && (i % 2) == 1 )) && outmac="${outmac}."
done

echo "$MAC --> $outmac"

which gives the following output
Code:
0:1c:c9:2a:b6:77 --> 001c.c92a.b677

# 4  
Old 04-15-2009
Quote:
Originally Posted by zaxxon
Awful long but works:
Code:
echo "0:1c:c9:2a:b6:77"| tr -s ':' '\n'|  sed 's/^.$/0&/'| tr -d '\n'| sed 's/\(....\)\(....\)\(....\)/\1\.\2\.\3\n/g'
001c.c92a.b677


Thanks for the responses.

I am on Solaris 10. This does not seem to work?
HTML Code:
tr -d '\n'
??

Previous Thread | Next Thread
Test Your Knowledge in Computers #458
Difficulty: Medium
NTP uses a flat, peer-to-peer system of time sources.
True or False?

5 More Discussions You Might Find Interesting

1. IP Networking

How to stack Cisco 2960-S and Cisco 2960X?

Is there an easy way to stack Cisco 2960-S and Cisco 2960X switches? If you have no idea, follow this: 1. Stacking is not supported on switches running the LAN Lite image. All switches in the stack must be running the LAN Base image. 2. In a mixed stack of Catalyst 2960-X and Catalyst 2960-S... (0 Replies)
Discussion started by: Ayaerlee
0 Replies

2. UNIX for Dummies Questions & Answers

Help with Unix/Mac OS question

Hope someone can help give me a clue what is going on here, I work in a Macintosh computer lab in a college institution and currently we run Mac G4's with what is becoming dated software but everything has been fine until recently, when a new student purchased a new Mac G5 system in order to do her... (1 Reply)
Discussion started by: kd4rmm
1 Replies

3. UNIX for Dummies Questions & Answers

Mac OS X Question

I've looked at all the forums here, and could not find my answer! I don't use a Mac, But have Played with OS X. It is Unix based I know that, but can you Install all the free programs like you can on *BSD and Lunix? MacIain (1 Reply)
Discussion started by: MacIain
1 Replies

4. UNIX for Dummies Questions & Answers

mac os question

i would like to ask those who know of the subject to please answer this question. could it be possible to somehow run mac os x in a newly built computer of mine. the computer i made myself (a clone) and it runs linux just nicely. would there be some way to emulate mac os x to be compatible for... (2 Replies)
Discussion started by: ChildrenoftheOS
2 Replies

5. UNIX for Dummies Questions & Answers

Mac OSX question

Hi. Is it possible to execute a Cocoa (or Carbon or eaven a classic) program for mac OSX in the terminal window? OSX finder can sometimes be so busy that it wont respond for several minutes, ie if you are uploading a very big file/files to a afp server. Then it would have been nice to start... (7 Replies)
Discussion started by: nicke30
7 Replies

Featured Tech Videos