LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 12-30-2004, 09:20 PM   #1
predator.hawk
Member
 
Registered: Aug 2004
Location: USA
Distribution: FreeBSD-5.4-STABLE
Posts: 252

Rep: Reputation: 30
Network Device Names


I'd like to know if its possible to use grep to retreive a network device name dynamicaly. I'd like to integrate this with my firewall script so that i can dynamicaly control device names.

Thanks in advance.
 
Old 12-31-2004, 04:37 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
what do you actually wish to achieve? sure you can get device names via /sbin/ifconfig and go from there... is that all you're after?
 
Old 12-31-2004, 12:32 PM   #3
predator.hawk
Member
 
Registered: Aug 2004
Location: USA
Distribution: FreeBSD-5.4-STABLE
Posts: 252

Original Poster
Rep: Reputation: 30
yes, but i want to cut off everything BUT the device name. meaning if the device name is eth0, i only get eth0 and nothing else.

Last edited by predator.hawk; 12-31-2004 at 12:34 PM.
 
Old 01-03-2005, 02:07 PM   #4
tlowk
Member
 
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 151

Rep: Reputation: 23
/sbin/ifconfig | cut -f 1 -d ' ' | grep '^[a-z]'

in your script this might be used like below

#!/bin/sh
n=0
for line in `/sbin/ifconfig | cut -f 1 -d ' ' | grep '^[a-z]'`
do
n=$((n+1)) ; NIC[$n]=$line
done

echo 'Device 0 ' ${NIC[0]}
echo 'Device 1 ' ${NIC[1]}
echo 'Device 2 ' ${NIC[2]}


# end of suggested script


Tlowk
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Device names Fredstar *BSD 2 06-17-2005 08:03 PM
Logical device names and instant names Gins Linux - General 8 11-30-2004 08:17 PM
newbee device names help oldstinkyfish Linux - Hardware 3 11-24-2003 02:25 PM
Mounted Device names Rodzilla Linux - Newbie 7 09-25-2003 10:39 AM
How to determine device names yian Linux - General 2 10-21-2002 07:56 PM


All times are GMT -5. The time now is 08:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration