On 10/26/10 11:09 AM, [email protected] wrote:
On (10/26/10 10:43), Sunay Tripathi wrote:

  BTW, we probably need to deliver libipadm.h (and perhaps rename it
  to ipadm.h). At least till b137, I didn't see it on a installed
  system (perhaps the already fixed later).

  Cheers,
  Sunay

I think this follows the libdladm model- since the interfaces are
not Committed yet, we don't ship the header file.. the CLI is a different
story.

I don't have a fully installed system with me right now but I think
we do ship libdladm.h. Either way, if we want people to use the APIs
even if they are experimental, we need to ship the header files.

Cheers,
Sunay


--Sowmini


  On 10/26/10 07:04 AM, Dave Miner wrote:
As ipadm is now the preferred interface for obtaining IP configuration
information, I'd suggest using it instead, which likely leads in a
different direction entirely.

Dave

On 10/25/10 08:55 PM, Jack Schwartz wrote:
Hi everyone.

I'm trying to do a sed one-liner but can't seem to get it to work...

I want to parse ifconfig -a output and print the line which follows the
line with the regular expression of "BROADCAST.*IPv4". End goal is to
get the IP Address and netmask of the first non-loopback IPv4 interface.

So when I see this:
---
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>  mtu
8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4>  mtu
1500 index 3
inet 10.132.145.68 netmask fffffe00 broadcast 10.132.145.255
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL>  mtu
8252 index 1
inet6 ::1/128
e1000g0: flags=20002004841<UP,RUNNING,MULTICAST,DHCP,IPv6>  mtu 1500
index 3
inet6 fe80::223:18ff:fe72:3644/10
schwa...@jslaptop:~/test$ ifconfig -a | grep BROADCAST | grep IPv4
e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4>  mtu
1500 index 3
---

I want to output this:
inet 10.132.145.68 netmask fffffe00 broadcast 10.132.145.255

Everywhere I google I see that the following should work:
ifconfig -a | /usr/bin/sed -n '/BROADCAST.*IPv4/{n;p}'

but I get an error with /usr/bin/sed instead:
sed: command garbled: /BROADCAST.*IPv4/{n;p}

More confusing to me is when I remove the {} I get too much output:

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>  mtu
8232 index 1
inet 127.0.0.1 netmask ff000000
inet 10.132.145.68 netmask fffffe00 broadcast 10.132.145.255
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL>  mtu
8252 index 1
inet6 ::1/128
e1000g0: flags=20002004841<UP,RUNNING,MULTICAST,DHCP,IPv6>  mtu 1500
index 3
inet6 fe80::223:18ff:fe72:3644/10

(actually, this is all the lines except the one I am searching for)

When I run gnu sed, then it works.

ifconfig -a | /usr/gnu/bin/sed -n '/BROADCAST.*IPv4/ {n;p}'
inet 10.132.145.68 netmask fffffe00 broadcast 10.132.145.255

Questions:
1) Is using gnu sed a problem if this code is for an auto-installer
project?
2) What am I doing incorrectly above? How do I "un-garble" the
/usr/bin/sed command?

Thanks,
Jack
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss


_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

Reply via email to