all ip addresses of machines in the local network

D

damacy

hi, there. i have a problem writing a program which can obtain ip
addresses of machines running in the same local network.

say, there are 4 machines present in the network; [a], , [c] and [d]
and if i run my program on [a], it should be able to find "host names"
and "ip addresses" of the other machines; , [c] and [d]?

i have read some threads posted on this group, however, they only work
for localhost, not the entire network.

any hints if possible?

thanks for your time.

regards, damacy
 
S

Sandra-24

damacy said:
hi, there. i have a problem writing a program which can obtain ip
addresses of machines running in the same local network.

say, there are 4 machines present in the network; [a], , [c] and [d]
and if i run my program on [a], it should be able to find "host names"
and "ip addresses" of the other machines; , [c] and [d]?

i have read some threads posted on this group, however, they only work
for localhost, not the entire network.

any hints if possible?

thanks for your time.

regards, damacy


What is this for? Some kind of high availablity server setup? I don't
know anything that would be useful to you, but I am curious, and maybe
it will clarify your intentions for others.

-Sandra
 
D

damacy

hi, sandra.

no, it's not as complicated as that. all i want to do is to load a
database onto different machines residing in the same network. i hope
there is a way doing it. or perhaps i have a poor understanding of how
networks work.

regards, damacy

Sandra-24 said:
damacy said:
hi, there. i have a problem writing a program which can obtain ip
addresses of machines running in the same local network.

say, there are 4 machines present in the network; [a], , [c] and [d]
and if i run my program on [a], it should be able to find "host names"
and "ip addresses" of the other machines; , [c] and [d]?

i have read some threads posted on this group, however, they only work
for localhost, not the entire network.

any hints if possible?

thanks for your time.

regards, damacy


What is this for? Some kind of high availablity server setup? I don't
know anything that would be useful to you, but I am curious, and maybe
it will clarify your intentions for others.

-Sandra
 
J

John Bokma

damacy said:
hi, there. i have a problem writing a program which can obtain ip
addresses of machines running in the same local network.

say, there are 4 machines present in the network; [a], , [c] and [d]
and if i run my program on [a], it should be able to find "host names"
and "ip addresses" of the other machines; , [c] and [d]?

i have read some threads posted on this group, however, they only work
for localhost, not the entire network.

any hints if possible?


google for nmap, don't reinvent the wheel.
 
M

mbstevens

hi, sandra.

no, it's not as complicated as that. all i want to do is to load a
database onto different machines residing in the same network. i hope
there is a way doing it. or perhaps i have a poor understanding of how
networks work.

It would not be 'as complicated as that' if we knew the kind of
network you are on -- NFS, Samba, Windows, some hybred network,
SSH, FTP, telnet, remote X, remote desktops? Every service has its
own way of doing things.
 
J

John Bokma

damacy said:
hi, sandra.

If you reply like is common on Usenet, there is no need to address
someone, since the attribution line is just there:

Sandra-24 wrote:
^^^^^^^^^^^^^^^

Google for top posting, and read why it's generally considered bad.
no, it's not as complicated as that. all i want to do is to load a
database onto different machines residing in the same network.

if they are all in the xx.yy.zz.ii range, with ii the only number that
varies, you could ping each ii with a short time out. No reply = nothing
on it (unless pings are blocked).
 
A

Amit Khemka

hi, sandra.

no, it's not as complicated as that. all i want to do is to load a
database onto different machines residing in the same network. i hope
there is a way doing it. or perhaps i have a poor understanding of how
networks work.

I expect that you would know the IP range for your network. Then you
can simply 'ping' each IP in the range to find wether its alive.
Moreover by your description I guess you would actually want to find
all machines in your network that run a particular network service, to
allow you to "distribute the database". In such case you can use
"nmap" with -p option, to find all the machines which are listening on
the particular port.

hth,
amit.
 
A

Amit Khemka

I expect that you would know the IP range for your network. Then you
can simply 'ping' each IP in the range to find wether its alive.
Moreover by your description I guess you would actually want to find
all machines in your network that run a particular network service, to
allow you to "distribute the database". In such case you can use
"nmap" with -p option, to find all the machines which are listening on
the particular port.

hth,
amit.
It seems that I am not too busy, so here is a code which may work with
a few tweaks here and there:
_________________________________________________________________________
import os
# base and range of the ip addresses
baseIP = "10.0.0."
r = 6
interestingPort = 22 # port that you want to scan
myIPs = []

for i in range(r):
ip = baseIP+str(i) # It may need some customization for your case
print "scanning: %s" %(ip)
for output in os.popen("nmap %s -p %s" %(ip,
interestingPort)).readlines():
if output.__contains__('%s/tcp open'
%interestingPort): # i guess it would be tcp
myIPs.append(ip)
__________________________________________________________________________
print myIPs


hth,
amit.
--
 
T

tobiah

I am a member of another list that has at least one member
who has lost his vision, and reads his news with a speech
generator. It is terribly inconvenient for him to follow
a thread full of 'bottom postings', as he is then forced to
sit through the previous message contents again and again
in search of the new content.
 
J

John Bokma

tobiah said:
I am a member of another list that has at least one member
who has lost his vision, and reads his news with a speech
generator. It is terribly inconvenient for him to follow
a thread full of 'bottom postings', as he is then forced to
sit through the previous message contents again and again
in search of the new content.

Yes, that's why it's also recommended to *remove all lines you're not
replying to*. A full quote is always annoying (unless it's really needed
to get some context, which is in general rare).

Not only people with a vision problem will be thankful for that. Like I
recommended to *read* on top posting, instead of repeating myths that are
made up by people who are ignorant.

Simple recipe:
http://johnbokma.com/mexit/2006/04/11/how-to-reply.html

I am sure that people with a vision problem who jump into the thread
prefer a small context over listening "upside down" to get some context, I
mean:

A: top posting
Q: what is the most annoying thing on Usenet

Now imagine that Q is quote after quote after qoute because a hand ful of
lazy clueless bastards want to save time.
 
C

Chaz Ginger

I was writing some code that used someone else class as a subclass. He
wrote me to tell me that using his class as a subclass was incorrect. I
am wondering under what conditions, if ever, does a class using a
subclass not work.

Here is an example. For instance the original class might look like:

class A :
def __init__(self,arg) :
self.foo = arg
def bar(self) :
return self.foo


And I defined a class B1 which looked like:


class B1(A);
def __init__(self,a1,a2) :
self.c = a1
A.__init__(self,ag)


He said I should use it this way:

class B2:
def __init__(self,a1,a2):
self.c = a1
self.t = A(a2)

def bar(self) :
self.t.bar()


Other than the obvious difference of B2 having an attribute 't', I can't
see any other obvious differences. Is there something I am missing?

TIA
Chaz
 
T

Tim Chase

I am a member of another list that has at least one member
who has lost his vision, and reads his news with a speech
generator. It is terribly inconvenient for him to follow
a thread full of 'bottom postings', as he is then forced to
sit through the previous message contents again and again
in search of the new content.

I'm involved on the Blind Linux users (Blinux) list, and they
seem to have no problem bottom-posting.

There are a variety of tools for converting bottom-posting into
more readable formats. If you want to suppress comments, a
quality MUA can suppress them. Or you can pipe them through
sed/grep/whatever and strip out all lines beginning with a
greater-than sign. Or, use the search functionality in the
screen-reader to skip ahead to the next line until you get to one
that doesn't begin with a greater-than sign. Some text-display
areas even allow you to use searching to move the cursor. E.g.
if reading a mail in mutt in a console, you can open it in vim
and search for "^[^>]" which will move the cursor to the next
line that doesn't begin with a greater-than sign. Quite usable
from within yasr ("yet another screen reader").

Inspired by a problem discussed on the Blinux list, I've also
created a python tool for converting standard quoting notation
(using greater-than signs) into a more TTS-friendly
(text-to-speech) format:

http://www.redhat.com/archives/blinux-list/2006-June/msg00012.html
http://www.redhat.com/archives/blinux-list/2006-June/msg00015.html
http://www.redhat.com/archives/blinux-list/2006-June/msg00016.html

Thus, there are tools for blind/visually-impared folks that can
make it easier for them to correspond using the standards the
rest of the world uses. Even among blind users, there's often a
division between those that use Braille terminals and those that
use TTS. Those using Braille tend to fall in with the rest of
the internet, preferring bottom-posting. Those using TTS aren't
quite so fond of having their own content regurgitated back to
them. However, judicial pruning of quoted contend can ease that
problem.

Thus, there are plenty of tools to help BVI folks operate under
the standard of bottom-posting.

-tkc
 
F

Fredrik Lundh

please don't hit reply to arbitrary messages when you're posting new
messages; it messes up the message threading.

Chaz said:
I was writing some code that used someone else class as a subclass. He
wrote me to tell me that using his class as a subclass was incorrect. I
am wondering under what conditions, if ever, does a class using a
subclass not work.

your terminology is confused: if you inherit from another class, *your*
class is the subclass, while the class you inherit from is known as a
"base class" or "super class".

a subclass will share the instance namespace with the base class, which
means, among other things, that you may accidentally override internal
attributes and methods, and thus break the base class.

and even if it appears to work now, it may break when you upgrade the
base class. or when you end up in a code path that you haven't tested
before.

</F>
 
C

Chaz Ginger

Fredrik said:
please don't hit reply to arbitrary messages when you're posting new
messages; it messes up the message threading.



your terminology is confused: if you inherit from another class, *your*
class is the subclass, while the class you inherit from is known as a
"base class" or "super class".

a subclass will share the instance namespace with the base class, which
means, among other things, that you may accidentally override internal
attributes and methods, and thus break the base class.

and even if it appears to work now, it may break when you upgrade the
base class. or when you end up in a code path that you haven't tested
before.

</F>
Sorry for the threading screw up. I thought I had just hit the write button.

I understand when my class overrides the super class. But that would
just be "normal" class related things. I was wondering if there was
something more subtle I am missing in Python class handling.

Chaz
 
C

Chaz Ginger

Fredrik said:
please don't hit reply to arbitrary messages when you're posting new
messages; it messes up the message threading.



your terminology is confused: if you inherit from another class, *your*
class is the subclass, while the class you inherit from is known as a
"base class" or "super class".

a subclass will share the instance namespace with the base class, which
means, among other things, that you may accidentally override internal
attributes and methods, and thus break the base class.

and even if it appears to work now, it may break when you upgrade the
base class. or when you end up in a code path that you haven't tested
before.

</F>
Sorry for the threading screw up. I thought I had just hit the write button.

I understand when my class overrides the super class. But that would
just be "normal" class related things. I was wondering if there was
something more subtle I am missing in Python class handling.

Chaz
 
G

Gabriel Genellina

I was writing some code that used someone else class as a subclass. He
wrote me to tell me that using his class as a subclass was incorrect. I
am wondering under what conditions, if ever, does a class using a
subclass not work.

class B1(A);
def __init__(self,a1,a2) :
self.c = a1
A.__init__(self,ag)

class B2:
def __init__(self,a1,a2):
self.c = a1
self.t = A(a2)

def bar(self) :
self.t.bar()

Other than the obvious difference of B2 having an attribute 't', I can't
see any other obvious differences. Is there something I am missing?

Look any OO book for the difference between 'inheritance' and
'delegation'. In short, you should inherit when B 'is an' A (a Car is
a Vehicle), and delegate/compose in other cases (a Car has an Engine;
or more precisely, a Car instance has an Engine instance).


Gabriel Genellina
Softlab SRL



p5.vert.ukl.yahoo.com uncompressed Thu Aug 24 19:27:05 GMT 2006


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
C

Carl Banks

Chaz said:
I was writing some code that used someone else class as a subclass. He
wrote me to tell me that using his class as a subclass was incorrect. I
am wondering under what conditions, if ever, does a class using a
subclass not work. [snip]
He said I should use it this way:

class B2:
def __init__(self,a1,a2):
self.c = a1
self.t = A(a2)

def bar(self) :
self.t.bar()

Other than the obvious difference of B2 having an attribute 't', I can't
see any other obvious differences. Is there something I am missing?

I think it's kind of a fine point. In my own code I've had cases where
I've switched from subclass to attribute and back over the development,
and vice versa. I think there are many cases where it's preferable to
use an attribute, but not really wrong to subclass (and vice versa).

The classical advice in choosing whether to subclass or or use
attribute is whether its more an an "is a" or "has a" relationship. If
it's more natural to say B is an A, then subclass. If it's more
natural to say B has an A, then use an attribute. But that's only a
rule of thumb.

I personally find another question helpful. If it's reasonable that B
could have more than one of A, regardless if it actually does, use an
attribute. If it's unreasonable, subclass. Again, rule of thumb.


Carl Banks
 
C

Chaz Ginger

Gabriel said:
Look any OO book for the difference between 'inheritance' and
'delegation'. In short, you should inherit when B 'is an' A (a Car is a
Vehicle), and delegate/compose in other cases (a Car has an Engine; or
more precisely, a Car instance has an Engine instance).


Gabriel Genellina
Softlab SRL


p5.vert.ukl.yahoo.com uncompressed Thu Aug 24 19:27:05 GMT 2006

__________________________________________________ Preguntá. Respondé.
Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en
Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas

That is merely a logical use of OO after all when would a car and an
orange be the same?

I was wondering more about the mechanics of Python: when does B1 show
different characteristics than B2 (forgoing the obvious simple things,
like 't' above).

Chaz
 
C

Chaz Ginger

Gabriel said:
Look any OO book for the difference between 'inheritance' and
'delegation'. In short, you should inherit when B 'is an' A (a Car is a
Vehicle), and delegate/compose in other cases (a Car has an Engine; or
more precisely, a Car instance has an Engine instance).


Gabriel Genellina
Softlab SRL


p5.vert.ukl.yahoo.com uncompressed Thu Aug 24 19:27:05 GMT 2006

__________________________________________________ Preguntá. Respondé.
Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en
Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas

That is merely a logical use of OO after all when would a car and an
orange be the same?

I was wondering more about the mechanics of Python: when does B1 show
different characteristics than B2 (forgoing the obvious simple things,
like 't' above).

Chaz
 
B

Ben Finney

Tim Chase said:
I'm involved on the Blind Linux users (Blinux) list, and they seem
to have no problem bottom-posting.

There are a variety of tools for converting bottom-posting into more
readable formats. If you want to suppress comments, a quality MUA
can suppress them.

The parent poster is complaining about a straw man. As they point out,
"bottom posting" is almost as bad as top posting. Both practices leave
the entire content of quoted material intact, regardless of which
parts are relevant.

The correct solution to both top posting *and* bottom posting is
"interleaved posting", but more importantly to trim away everything
except the quoted material necessary for giving context to one's
response. This is of even greater assistance to the blind, who then
have just the necessary context to understand the current message.

<URL:http://en.wikipedia.org/wiki/Top_posting>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top