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
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
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
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
> 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")
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'
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
> 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?
>>
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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: (.+?)",
"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
"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
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.
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:
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
33 matches
Mail list logo