script to get IP address from ifconfig


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to get IP address from ifconfig
# 8  
Old 12-30-2008
you stripped one of the awks out of the command:

ifconfig ppp0 | grep "inet addr" | awk '{ print $2 }' | awk 'BEGIN { FS=":" } { print $2 }' | awk ' BEGIN { FS="." } { print $1 "." $2 "." $3 ".0" }'
Padow
# 9  
Old 12-30-2008
perfect..thank you!
# 10  
Old 12-31-2008
Quote:
Originally Posted by speedy3k
..but man is it harder than writing a simple .bat file!
Smilie
A bat file? Man, I hope that was said tongue-in-cheek. It may not be apparent yet, but the bash shell is incredibly more powerful, capable and flexible than any bat file.

I used to write very elaborate bat files, but now I get depressed on the rare occasion I am that limited.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with ifconfig shell script

I am new to shell scripting and trying to create a shell script which will extract and print only ip address from ifconfig command and not all the information. I have two issues here - 1. To know active interface like eth0, wl0, etc. - I guess `route` command will give me interface name in last... (3 Replies)
Discussion started by: amarshukla
3 Replies

2. Shell Programming and Scripting

extracting the ip address from ifconfig

Hi I am trying to create a script extracting the IP provided by ifconfig. I tried with grep + awk but I am returned more than I need. /sbin/ifconfig eth0 | grep "inet addr:" | awk '/inet addr:/ { print $2 }' and returns addr:10.15.1.64 How can I remove "addr:" string?... (9 Replies)
Discussion started by: manustone
9 Replies

3. Solaris

ifconfig - making netmask & broadcast address permanent?

hi, I am trying to configure one of my interfaces, but after reboot - i lose the changes to the netmask & broadcast address. I have added an entry in /etc/netmasks, but it doesnt pick up the new settings. any ideas - much appreciated. before reboot: eri0:... (3 Replies)
Discussion started by: badoshi
3 Replies

4. Shell Programming and Scripting

How do I set up a shell script using ifconfig?

I am running on AIX 5.3. I have a remote AIX server running on a generator. Many times the generator goes out and I only have a window of 15 mins with the network up and 30 mins the server is powered. I need help creating a script using ifconfig, where it goes out and checks the network every 5... (2 Replies)
Discussion started by: AIX25
2 Replies

5. IP Networking

IP Address not found in ifconfig/netstat

I'm working on an AIX Unix LPAR (AIX 3.5 00C3C9904C00 as returned by uname -a) I can access this box using telnet, port 22 using adress IP A and B A=AA.AA.XX.XX and B=AA.AA.YYY.YYY I can confirm these 2 are the same space, I can see I can't find address B listed anywhere... so I wonder what... (1 Reply)
Discussion started by: Isax50
1 Replies

6. Shell Programming and Scripting

how to grep only IP address of e1000g0 using ifconfig -a

Hello All, Can someone show me how to cat "only the IP address of e1000g0" using ifconfig -a. i am trying to grep only the ip address (xx.xx.xx.xx) from the bunch of all other things like, broadcast address, IPV4, UP........and so on. thanks (1 Reply)
Discussion started by: solaix14
1 Replies

7. Shell Programming and Scripting

how grep the inet address for in ifconfig command

hi, i want to know how to grep inet address for below below is the output of ifconfig command /home/JA> ifconfig eth0 Link encap:Ethernet HWaddr 00:11:0A:5B:2E:E9 inet addr:161.239.203.18 Bcast:161.239.203.127 Mask:255.255.255.128 UP BROADCAST RUNNING... (3 Replies)
Discussion started by: mail2sant
3 Replies

8. IP Networking

ifconfig: ce401001: bad address

HI All, My interface card has failed.If i am giving the command to uplumb it i am getting an error. ce401001: flags=219040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER,FAILED,CoS> mtu 1500 index 3 inet 10.188.24.18 netmask ffffffc0 broadcast 10.188.24.63 # ifconfig... (2 Replies)
Discussion started by: sag71155
2 Replies

9. IP Networking

Setting primary ip address with ifconfig

Hello, I have a server with two ip addresses. I need to make the ip address that's currently the secondary the primary. How do I use the ifconfig command and primary option? Thanks. (5 Replies)
Discussion started by: pmichner
5 Replies

10. Solaris

ifconfig bad address

hi all iam trying to set my eri0 interface but with little luck . when i set the ip using ipconfig i always get "bad adress".. moreover when i use ifconfig eri0 i can notice that the inet is 0.0.0.0 and the netmask 0 i am runnig solaris 9 on sparc . any helpis highly appreciated ... ... (2 Replies)
Discussion started by: ppass
2 Replies
Login or Register to Ask a Question