Re: IP address to binary conversion

2020-05-09 Thread al . alexiev
Hi Alan, Yes, agreed that any '!I' or '!L' combination will work on different type of platforms in a consistent manner, when applied in both directions. I was referring to Alex Martelli's output, where the conversion back to IP seems to be reversed, even with '!L', which means that he's already

Re: IP address to binary conversion

2020-05-08 Thread Alan Bawden
al.alex...@gmail.com writes: > Just for the records and to have a fully working bidirectional solution: > > >>> ip > '10.44.32.0' > >>> struct.unpack('L', socket.inet_aton(ip))[0] > 2108426 > >>> socket.inet_ntoa(struct.pack(' '10.44.32.0' > >>> > > Good luck ;-) This will not work as expected

Re: IP address to binary conversion

2020-05-08 Thread al . alexiev
Just for the records and to have a fully working bidirectional solution: >>> ip '10.44.32.0' >>> struct.unpack('L', socket.inet_aton(ip))[0] 2108426 >>> socket.inet_ntoa(struct.pack('>> Good luck ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: IP Address Function

2009-07-09 Thread Tim Roberts
Fred Atkinson wrote: > >I wonder why they don't just have a function to return it instead of >putting you through all of that? In CGI, EVERYTHING gets communicated through environment variables. That (and the stdin stream) is really the only option, since you get a new process for every reques

Re: IP Address Function

2009-07-09 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum >FA> wrote: >>> Something like: >>> >>> #! /usr/bin/env python >>> >>> import cgi >>> from os import getenv >>> >>> print "Content-type: text/html" >>> print >>> >>> ipaddr = (getenv("HTTP_CLIENT_IP")

Re: IP Address Function

2009-07-08 Thread Nobody
On Wed, 08 Jul 2009 20:53:12 -0700, Fred Atkinson wrote: >>ipaddr = (getenv("HTTP_CLIENT_IP") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("REMOTE_ADDR") or >> "UNKNOWN") >> >>print ipaddr > > That did it. > > I wonder why they don'

Re: IP Address Function

2009-07-08 Thread Fred Atkinson
On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum wrote: >Something like: > >#! /usr/bin/env python > >import cgi >from os import getenv > >print "Content-type: text/html" >print > >ipaddr = (getenv("HTTP_CLIENT_IP") or > getenv("HTTP_X_FORWARDED_FOR") or > getenv("HTTP_X_FORWARDED_F

Re: IP Address Function

2009-07-08 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina" >FA> wrote: >>> En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson >>> escribió: >>> Is there a Python function I can use to get the user's IP address so I can display it on his browser? >>

Re: IP Address Function

2009-07-08 Thread Fred Atkinson
On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina" wrote: >En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson >escribió: > >> Is there a Python function I can use to get the user's IP >> address so I can display it on his browser? > >There is a long distance between "Python" and "brow

Re: IP Address Function

2009-07-07 Thread Gabriel Genellina
En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson escribió: Is there a Python function I can use to get the user's IP address so I can display it on his browser? There is a long distance between "Python" and "browser" - you'll have to tell us what is in between the two. By example

Re: IP Address Function

2009-07-07 Thread Chris Rebert
On Tue, Jul 7, 2009 at 6:45 PM, Fred Atkinson wrote: >        Is there a Python function I can use to get the user's IP > address so I can display it on his browser? from socket import gethostname, gethostbyname ip = gethostbyname(gethostname()) Cheers, Chris -- http://blog.rebertia.com -- http

Re: IP Address Function

2009-07-07 Thread Tim Harig
On 2009-07-08, Fred Atkinson wrote: > Is there a Python function I can use to get the user's IP > address so I can display it on his browser? If you are using CGI you can get it from the REMOTE_ADDR environmental variable. -- http://mail.python.org/mailman/listinfo/python-list

Re: Ip address

2007-01-29 Thread Steve Holden
Toby A Inkster wrote: > Steve Holden wrote: > >> There is absolutely no need to know the IP address of "your router" to >> communicate with Internet devices. Either your IP layer is configured to >> know the addresses of one or more routers, or it has discovered those >> address by dynamic mean

Re: IP address

2007-01-29 Thread Scripter47
Beej skrev: > On Jan 28, 2:26 am, Klaus Alexander Seistrup <[EMAIL PROTECTED]> wrote: >> Scripter47 wrote: >>> How do i get my ip address? >>> in cmd.exe i just type "ipconfig" then it prints: >>> ... >>> IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 >>> ... >>> how

Re: Ip address

2007-01-28 Thread Adonis Vargas
Scripter47 wrote: > How do i get my ip address? > > in cmd.exe i just type "ipconfig" then it prints: > ... > IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 > ... > how can i do that in python?? > If you want to get your external IP you can do: import urllib checkIP

Re: IP address

2007-01-28 Thread Beej
On Jan 28, 2:26 am, Klaus Alexander Seistrup <[EMAIL PROTECTED]> wrote: > Scripter47 wrote: > > How do i get my ip address? > > > in cmd.exe i just type "ipconfig" then it prints: > > ... > > IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 > > ... > > how can i do that

Re: IP address

2007-01-28 Thread Garry Knight
Klaus Alexander Seistrup wrote: > urllib.urlopen("http://myip.dk/";) http://whatismyip.org gives it to you in a more usable format. But, as others have pointed out, it might return your router's IP. -- Garry Knight [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: IP address

2007-01-28 Thread Gabriel Genellina
At Sunday 28/1/2007 10:28, Colin J. Williams wrote: Klaus Alexander Seistrup wrote: > > python -c 'import re, urllib; print re.findall("Your IP: (.+?)", urllib.urlopen("http://myip.dk/";).read())[0]' > Your one-liner doesn't work for me, with Windows XP, but the following On XP you should s

Re: Ip address

2007-01-28 Thread Toby A Inkster
Scripter47 wrote: > How do i get my ip address? Which IP address. One computer might have many IP addresses. (Indeed a typical network-connected computer will tend to have at least one for each connected network device, plus the special address 127.0.0.1 for the loopback network.) How is Python s

Re: Ip address

2007-01-28 Thread Toby A Inkster
Steve Holden wrote: > There is absolutely no need to know the IP address of "your router" to > communicate with Internet devices. Either your IP layer is configured to > know the addresses of one or more routers, or it has discovered those > address by dynamic means, or you can't get off-net be

Re: Ip address

2007-01-28 Thread Steve Holden
Adam wrote: > Hey, > > This will get your IP address: > > ###Code > print socket.gethostbyaddr(socket.gethostname()) > ('compname', [], ['192.168.1.2']) > End Code > > If you are wanting to to communicate over the internet you will have > to get the IP of you rounter

Re: IP address

2007-01-28 Thread Klaus Alexander Seistrup
Colin J. Williams wrote: > Your one-liner doesn't work for me, with Windows XP, but the > following does, within Python. Could it be due to shell-escaping issues? I don't know anything about Windows... Cheers, -- Klaus Alexander Seistrup http://klaus.seistrup.dk/ -- http://mail.python.org

Re: IP address

2007-01-28 Thread Klaus Alexander Seistrup
Adam wrote: > This will get your IP address: > > ###Code > print socket.gethostbyaddr(socket.gethostname()) > ('compname', [], ['192.168.1.2']) > End Code It will return an IP address, but not necessarily the one you want: #v+ [EMAIL PROTECTED]:~ $ python -c 'import

Re: IP address

2007-01-28 Thread Colin J. Williams
Klaus Alexander Seistrup wrote: > Scripter47 wrote: > >> How do i get my ip address? >> >> in cmd.exe i just type "ipconfig" then it prints: >> ... >> IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 >> ... >> how can i do that in python?? > > #v+ > > python -c 'impo

Re: Ip address

2007-01-28 Thread Adam
Hey, This will get your IP address: ###Code print socket.gethostbyaddr(socket.gethostname()) ('compname', [], ['192.168.1.2']) End Code If you are wanting to to communicate over the internet you will have to get the IP of you rounter. So you will have to either find

Re: IP address

2007-01-28 Thread Klaus Alexander Seistrup
Scripter47 wrote: >> python -c 'import re, urllib; print re.findall("Your IP: >> (.+?)", urllib.urlopen("http://myip.dk/";).read())[0]' > > Hmm then you need Internet connecting. That's what IP adresses are for... > can i do it without that? Perhaps you could use the method mentioned in htt

Re: Mulig SPAM: Re: IP address

2007-01-28 Thread Scripter47
Klaus Alexander Seistrup skrev: > Scripter47 wrote: > >> How do i get my ip address? >> >> in cmd.exe i just type "ipconfig" then it prints: >> ... >> IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 >> ... >> how can i do that in python?? > > #v+ > > python -c 'impo

Re: IP address

2007-01-28 Thread Klaus Alexander Seistrup
Scripter47 wrote: > How do i get my ip address? > > in cmd.exe i just type "ipconfig" then it prints: > ... > IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10 > ... > how can i do that in python?? #v+ python -c 'import re, urllib; print re.findall("Your IP: (.+?)",

Re: IP address of webserver

2007-01-27 Thread Gabriel Genellina
"Johny" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > How can I find server's IP address? >>From console I can use ping, for example: > > C:\RobotP\cgi-bin>ping www.google.com > Pinging www.google.com [209.85.129.147] with 32 bytes of data: > [...] > But how can I find it di

Re: IP address of webserver

2007-01-27 Thread Paul Rubin
"Johny" <[EMAIL PROTECTED]> writes: > So I know that www.google.com has 209.85.129.147 IP address. > But how can I find it directly from Python script? >>> import socket >>> print socket.gethostbyname('www.google.com') 66.102.7.147 >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: IP address

2006-08-10 Thread Lad
Sybren Stuvel wrote: > Lad enlightened us with: > > I have a website written in Python and I would like to login every > > visitor's IP address. > > Ehm... that's probably "log" not "login". > > > In other words, if a visitor come to my Python application, this > > application will record his IP.

Re: IP address

2006-08-10 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Lad wrote: > I have a website written in Python and I would like to login every > visitor's IP address. > In other words, if a visitor come to my Python application, this > application will record his IP. Depending on what CGI framework you're using, something like:

Re: IP address

2006-08-10 Thread Lad
Sybren Stuvel wrote: > Lad enlightened us with: > > I would like to record visitor's IP address.How can I do that in > > Python? > > Too little information. Visitors of what? > > Sybren I have a website written in Python and I would like to login every visitor's IP address. In other words, if a v