Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 1st August 2007, 05:07
schris403 schris403 is offline
Junior Member
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default env variable mac address script problems

I have been trying for days to try and get the following script to load the mac variable upon boot in the rc.local file and just can't seem to get it to work. It does work when I manually run the line but when I run it as a normal sh script, it doesn't work.

mac=`ifconfig -a eth0 | grep "HWaddr" | cut -d " " -f 11` | tr -s : .

Maybe there is a different way of accomplishing this, all I want is a variable with my eth0 mac address with . instead of : seperating them. Any help would be greatly appreciated.

Thanks so much!!

Reply With Quote
Sponsored Links
Old 2nd August 2007, 18:28
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts

Have you tried to use the full paths for ifconfig, grep, cut, and tr in your script?
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Old 4th August 2009, 00:35
gymno gymno is offline
Junior Member
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: env variable mac address script problems

I agree with previous post ensure you have the correct path names.

However, when I tried the command in bash it didn't work.

I did get this to work:

ifconfig | grep "HWaddr" | cut -d" " -f11 | tr -s ":" "."

and that seemed to get the job done.

Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sending e-mail using mail() function linuxuser1 HOWTO-Related Questions 38 21st April 2009 13:20
apache2 problem laser144 Server Operation 8 15th March 2007 18:32
MAC address muzica Server Operation 5 12th March 2007 13:56
Can IPCop bandwidth throttle/shape by subnet, user or mac address? Merp HOWTO-Related Questions 3 15th July 2006 14:29
Ethereal Trouble mcrosby Installation/Configuration 8 25th June 2006 04:50

All times are GMT +2. The time now is 03:39.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.