473,808 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2414
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********@fas twebnet.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').r ead()
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
48767
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 guys!
8
4095
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 imcp packages, but I guess there must be a workaround since I can easily use the "ping" command as ordinary user. Do anybody know how to do this in python?
1
1709
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 out" If we ping to any other machines from thes two it's pinging, with ip also it's not pinging. any solution plz..... thanks in advance...
2
1441
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) to see their currently status every 5 mins. What Protocol do I use and why?
3
9192
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 arguments that would tell on which interpreter to run the string...? Marcin
2
2864
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 time out,when i m connection though vpn then error 721 come plz reply soon...
14
2663
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 run from within the editor or is that not how development is done? I ask because I was using Visual Studio with C# and, if you're familiar, you just hit run and it works. On Python do I use the editor for editing only and then run the program from...
3
1684
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 program.
1
1486
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 getting.Can any one help in this record. Thank u sidd4one
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10631
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.