How to ping a machine in a simple way?

Graham Fawcett graham__fawcett at hotmail.com
Wed May 14 14:01:32 EDT 2003


"Lexy Zhitenev" <zhitenev at cs.vsu.ru> wrote in message news:<b9sm31$28ni$1 at serv.vrn.ru>...
> Hello, Graham!
> You wrote on 13 May 2003 19:53:10 -0700:
> <snip>
>  GF> I wonder what you mean by "available?" Perhaps a ping is the wrong
>  GF> test, depending on what you're planning to do based on the results of
>  GF> the test.
> 
> I'll use one of the shares on this machine (reading and writing) after
> 'pinging'.

If the pinging machine is running Win2K (which you suggested), and
your ultimate goal it to read/write to shares, why not just query the
target machine for its shares using the win32 API?

C:\>python
ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32net
>>> print win32net.NetShareEnum('fawcett', 0)
([{'netname': u'IPC$'}, {'netname': u'public'}, ...<snip>...  ], 5, 0)
>>>

The first parameter is the hostname; the second parameter indicates
the level of detail; see the ActivePython docs for more info. (Mark
Hammond's Python Programming on Win32 is also an excellent resource
for all things win32.)

All the best,

-- Graham




More information about the Python-list mailing list