FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 02-19-2009, 10:43 AM
Hugo Vanwoerkom
 
Default ifconfig data

Hi,

Ifconfig says:

...
ppp0 Link encap:Point-to-Point Protocol
inet addr:200.57.201.43 P-t-P:200.57.219.18
Mask:255.255.255.255

...

I want that inet addr (200.57.201.43) in a program and I prefer not to
run the ifconfig command from it and grep it.


Does anyone know where else in the system that information resides?

I installed the net-tools source and looking at ifconfig.c it's not
immediately obvious.


Hugo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-19-2009, 12:02 PM
"Tanco ."
 
Default ifconfig data

Hi Hugo,

this will give you the IP

ifconfig ppp0 | grep "inet addr:" | awk '{ print $2}' | tail -c14

probably not the best solution, (the last part awk .... assumes your
IP has 14 chars) but this came to mind first .. do some experimenting



Hugo Vanwoerkom wrote:

Hi,

Ifconfig says:

...
ppp0 Link encap:Point-to-Point Protocol
inet addr:200.57.201.43 P-t-P:200.57.219.18
Mask:255.255.255.255

...

I want that inet addr (200.57.201.43) in a program and I prefer not to
run the ifconfig command from it and grep it.


Does anyone know where else in the system that information resides?

I installed the net-tools source and looking at ifconfig.c it's not
immediately obvious.


Hugo





--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-19-2009, 12:48 PM
Aneurin Price
 
Default ifconfig data

On Thu, Feb 19, 2009 at 11:43 AM, Hugo Vanwoerkom <hvw59601@care2.com> wrote:
> Hi,
>
> Ifconfig says:
>
> ...
> ppp0 Link encap:Point-to-Point Protocol
> inet addr:200.57.201.43 P-t-P:200.57.219.18 Mask:255.255.255.255
> ...
>
> I want that inet addr (200.57.201.43) in a program and I prefer not to run
> the ifconfig command from it and grep it.
>
> Does anyone know where else in the system that information resides?
>
> I installed the net-tools source and looking at ifconfig.c it's not
> immediately obvious.
>

Why don't you want to grep the output of ifconfig?

Maybe this would suit you:
http://www.geekpage.jp/en/programming/linux-network/get-ipaddr.php
(Changing eth0 to ppp0 obviously)

NB. To get that example to work I had to change the includes as follows:
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <unistd.h>

Nye


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-19-2009, 02:06 PM
Raquel
 
Default ifconfig data

On Thu, 19 Feb 2009 13:48:12 +0000
Aneurin Price <aneurin.price@gmail.com> wrote:

> On Thu, Feb 19, 2009 at 11:43 AM, Hugo Vanwoerkom
> <hvw59601@care2.com> wrote:
> > Hi,
> >
> > Ifconfig says:
> >
> > ...
> > ppp0 Link encap:Point-to-Point Protocol
> > inet addr:200.57.201.43 P-t-P:200.57.219.18
> > Mask:255.255.255.255 ...
> >
> > I want that inet addr (200.57.201.43) in a program and I prefer
> > not to run the ifconfig command from it and grep it.
> >
> > Does anyone know where else in the system that information
> > resides?
> >
> > I installed the net-tools source and looking at ifconfig.c it's
> > not immediately obvious.
> >
>
> Why don't you want to grep the output of ifconfig?
>

At your command prompt, do

$ apt-cache search dyndns

You'll get a list of 6 possible packages that may suit your needs.

--
Raquel
http://www.byraquel.com
================================================== ==========
Diversity is not for the squeamish. It means making (and taking) a
space at the table that includes people you don't like, don't agree
with, or who you think are just plain wrong.

--Alexander John Goodrum


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-19-2009, 04:45 PM
Hugo Vanwoerkom
 
Default ifconfig data

Aneurin Price wrote:

On Thu, Feb 19, 2009 at 11:43 AM, Hugo Vanwoerkom <hvw59601@care2.com> wrote:

Hi,

Ifconfig says:

...
ppp0 Link encap:Point-to-Point Protocol
inet addr:200.57.201.43 P-t-P:200.57.219.18 Mask:255.255.255.255
...

I want that inet addr (200.57.201.43) in a program and I prefer not to run
the ifconfig command from it and grep it.

Does anyone know where else in the system that information resides?

I installed the net-tools source and looking at ifconfig.c it's not
immediately obvious.



Why don't you want to grep the output of ifconfig?

Maybe this would suit you:
http://www.geekpage.jp/en/programming/linux-network/get-ipaddr.php
(Changing eth0 to ppp0 obviously)

NB. To get that example to work I had to change the includes as follows:
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <unistd.h>



Bingo! That is exactly what I was looking for! Thanks!

Hugo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-19-2009, 05:28 PM
Hugo Vanwoerkom
 
Default ifconfig data

Hugo Vanwoerkom wrote:

Aneurin Price wrote:
On Thu, Feb 19, 2009 at 11:43 AM, Hugo Vanwoerkom <hvw59601@care2.com>
wrote:

<snip>

Maybe this would suit you:

<snip>

To explain a little: I wrote a little program that analyzes the output
of apache2's access log. It puts just one message out to syslog if the
server is accessed many times. But I want to be the only one that
accesses it, so I need to know who I am. Now it puts out:


Feb 19 12:17:17 debian do_chk_aplog_3[22590]: 200.57.201.39 32 hits my
IP=200.57.201.39 (336)


That says that I accessed the server 32 times as myself. That would give
me a warning if anyone else accesses it, should be impossible because I
have the firewall blocked against it.

Thanks again for that page.

Hugo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-20-2009, 08:02 PM
Tzafrir Cohen
 
Default ifconfig data

On Thu, Feb 19, 2009 at 02:02:36PM +0100, Tanco . wrote:
> Hi Hugo,
>
> this will give you the IP
>
> ifconfig ppp0 | grep "inet addr:" | awk '{ print $2}' | tail -c14

ifconfig ppp0 | awk '/inet addr:/{ print $2}' | cut -d: -f2

--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-20-2009, 08:40 PM
Cameron Hutchison
 
Default ifconfig data

Tzafrir Cohen <tzafrir@cohens.org.il> writes:

>On Thu, Feb 19, 2009 at 02:02:36PM +0100, Tanco . wrote:
>> Hi Hugo,
>>
>> this will give you the IP
>>
>> ifconfig ppp0 | grep "inet addr:" | awk '{ print $2}' | tail -c14

> ifconfig ppp0 | awk '/inet addr:/{ print $2}' | cut -d: -f2

ifconfig ppp0 | awk '/inet addr:/{ split($2, a, ":"); print a[2] }'

Once you invoke awk, you may as well use it for all your string
manipulation.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 02-27-2009, 11:36 AM
"Andrew McGlashan"
 
Default ifconfig data

Hi,

Aneurin Price wrote:

Maybe this would suit you:
http://www.geekpage.jp/en/programming/linux-network/get-ipaddr.php
(Changing eth0 to ppp0 obviously)


Okay.


NB. To get that example to work I had to change the includes as


I got it to work fine without _any_ changes.

Kind Regards
AndrewM

Andrew McGlashan
Broadband Solutions now including VoIP


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 03-01-2009, 01:10 AM
Aneurin Price
 
Default ifconfig data

On Fri, Feb 27, 2009 at 12:36 PM, Andrew McGlashan
<andrew.mcglashan@affinityvision.com.au> wrote:
> Hi,
>
> Aneurin Price wrote:
>>
>> Maybe this would suit you:
>> http://www.geekpage.jp/en/programming/linux-network/get-ipaddr.php
>> (Changing eth0 to ppp0 obviously)
>
> Okay.
>
>> NB. To get that example to work I had to change the includes as
>
> I got it to work fine without _any_ changes.
>

That's interesting. I got a segfault, which turned out to be caused by
include problems; -Wall says:
test.c: In function ‘main’:
test.c:27: warning: implicit declaration of function ‘close’
test.c:30: warning: implicit declaration of function ‘inet_ntoa’
test.c:30: warning: format ‘%s’ expects type ‘char *’, but argument 2
has type ‘int’

I wonder why my headers don't declare the same things as yours...

Nye


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 05:28 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org