Pinging a machine from python

Sebastian 'lunar' Wiesner basti.wiesner at gmx.net
Sun May 25 13:48:13 EDT 2008


[ Prasanth <prasanths89 at gmail.com> ]

> I tried pinging a machine from python using socket programming but
> could not do it. Is there any module which we can use to ping the
> machine < like net::ping in perl> or can you give me simple program.
At least on linux pinging requires raw sockets since there is no syscall for
sending ICMP packages.  Raw sockets in turn require special privileges. 
Therefore its best to use the os command _ping_, this limits the use of
priviledges to the required part and you don't have to deal with
priviledges (ping has suid bit set).

net::ping will most likely do the same.

-- 
Freedom is always the freedom of dissenters.
                                      (Rosa Luxemburg)



More information about the Python-list mailing list