473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

pinging from within python

hi;

I need a simple script to run the ping command with some parameters and
be able to read the return value of the ping function. Any pointers will
be appreciated

thanks
m.smadi
Sep 11 '05 #1
4 2400
On 2005-09-11, M.N.A.Smadi <sm*****@grads.ece.mcmaster.ca> wrote:
I need a simple script to run the ping command with some parameters and
be able to read the return value of the ping function. Any pointers will
be appreciated


http://www.google.com/search?hl=en&q=python+ping

--
Grant Edwards grante Yow! I think my CAREER
at is RUINED!!
visi.com
Sep 11 '05 #2
Impacket module can helps you to construct the ip/icmp packet structure,
then you can send the packet and wait for the ECHOREPLY by using a
RAW_SOCKET.
Here's an example:
http://oss.coresecurity.com/impacket/ping.py

Cheers
I need a simple script to run the ping command with some parameters and be
able to read the return value of the ping function. Any pointers will be
appreciated

thanks
m.smadi

Sep 11 '05 #3
On Mon, 12 Sep 2005 01:36:35 +0200, billiejoex <bi********@fastwebnet.it> wrote:
Impacket module can helps you to construct the ip/icmp packet structure,
then you can send the packet and wait for the ECHOREPLY by using a
RAW_SOCKET.
Here's an example:
http://oss.coresecurity.com/impacket/ping.py


Yeah, but is he willing to be root, and ditch Windows, just to be able to
ping? Exec()ing the ping utility is often better, but beware -- different
pings take different options.

[the original poster]
I need a simple script to run the ping command with some parameters and be
able to read the return value of the ping function.


What is "the return value of the ping function"? You can use the ping
utility for many different things, and it reports many different kinds of
outcomes. It's not black and white.

/Jorgen

--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Sep 17 '05 #4
You can do the following:

import os

data = os.popen('ping machineName').read()
if 'request timed out' in data or 'unknown host' in data:
Ping Failed Code
else:
Ping Returned Something Good Code

This is the quickest and really most effective way to get it done IMO.

Harlin Seritt
Internet Villa: www.seritt.org

Sep 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tubby Tudor | last post by:
What is the best way to call one python script from within another python script? For example: one.py finishes succesfully and calls two.py which finishes OK and then calls three.py Thanks...
8
by: Thomas Dybdahl Ahle | last post by:
Hi, I've writing a python application in which I'd like to have a small "ping label", to always tell the current ping time to the server. It seems however that I have to be root to send those...
1
by: nethajireddy | last post by:
Hello techies In my office network all pc's are pinging and only two pc's let named as A and B, other are c,d.... if we ping A to B or B to A the result is "request time...
2
by: patelxxx | last post by:
Which Protocol do I use, when 'Pinging a server'? I am going to set up a Server status area on our companys website (sits on server A), the PERL coding will PING two other servers (server B & C)...
3
by: Marcin Kalicinski | last post by:
How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any...
2
by: gzali | last post by:
i am facing the problem that my live ip server is not pinging on my system i am using wireless connection pionts and the server pinging on some systems not all including me.when i m pinging server...
14
by: jmDesktop | last post by:
Hi, I'm trying to learn Python. I using Aquamac an emac implementation with mac os x. I have a program. If I go to the command prompt and type pythong myprog.py, it works. Can the program be...
3
by: Prasanth | last post by:
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 perlor can you give me simple...
1
by: sidd4one | last post by:
Hello, Hi experts when iam pinging from one of my system in the network. Its show iam "Unable to contact to ip adddress".This is message iam ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.