473,405 Members | 2,279 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,405 software developers and data experts.

TELNET instead PING

DCK
Hello :)

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):

"""
TelPing.py
- Simple Python script to probe workstation in WinNT Network

(c) 2004 Michal Kaczor (26.01.2004)
dc*@gazeta.pl
"""

import telnetlib
import sys
def tel_ping(tn_host,tn_port):
try:
tn = telnetlib.Telnet(tn_host,tn_port)
print 'Host:',tn_host,' Port:',tn_port,' <-- CONNECTED'
tn.close()
except:
print 'Host:',tn_host,' Port:',tn_port,' <-- Error: NO CONNECTION'
def main():
if (len(sys.argv)==3):
tel_ping(sys.argv[1],sys.argv[2])
else:
print 'Usage: telping.py <host> <port>'

if __name__ == "__main__":
main()
Jul 18 '05 #1
8 4341
DCK wrote:
Hello :)

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):


thanks a lot.
Can you do the same using ARP who-has request ? :)

Jul 18 '05 #2
DCK wrote:

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):


Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding.

from socket import *
s = socket(AF_INET, SOCK_STREAM)
try:
s.connect((host, port))
print 'host connected'
s.close()
except error:
print 'host not responding'

Should basically do the same job ...

-Peter
Jul 18 '05 #3

Peter Hansen wrote:
DCK wrote:

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):


Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding.

Exactly. All you need is an open port you can check.

Note: that reason you talked about is most likely a packet filtering
firewall. A good firewall
can block PING, Telnet, Nbsession and many others. In most cases, the
best policy
is to lock everything by default and permit only the ones you really
want. Firewall
rules can include source addresses too. It is possible that a computer
do not respond
on PING and TELNET ports for you but it does for a similar request from
another
computer. I think there is no universal way to determine if a remote
host is alive or not.
Jul 18 '05 #4
> Gandalf wrote:

I think there is no universal way to determine if a remote host is alive or not.


That is definitely the case, because of course the firewall could just as
easily block all traffic that is not from a specific IP address as well.

-Peter
Jul 18 '05 #5
Gandalf wrote:

Note: that reason you talked about is most likely a packet filtering
firewall. A good firewall
can block PING, Telnet, Nbsession and many others. In most cases, the
best policy
is to lock everything by default and permit only the ones you really
want. Firewall
rules can include source addresses too. It is possible that a computer
do not respond
on PING and TELNET ports for you but it does for a similar request from
another
computer. I think there is no universal way to determine if a remote
host is alive or not.


If we are talking about IP network segment in the same ethernet layer,
can you ignore my ARP request - who-has <your-ip> ?
Jul 18 '05 #6
>
Note: that reason you talked about is most likely a packet filtering
firewall. A good firewall
can block PING, Telnet, Nbsession and many others. In most cases, the
best policy
is to lock everything by default and permit only the ones you really
want. Firewall
rules can include source addresses too. It is possible that a
computer do not respond
on PING and TELNET ports for you but it does for a similar request
from another
computer. I think there is no universal way to determine if a remote
host is alive or not.

If we are talking about IP network segment in the same ethernet layer,
can you ignore my ARP request - who-has <your-ip> ?

Probably I cannot. :-)
But this applies only when you are in the same segment.
By the way, is it possible to send an ARP request from pure Python? ;-)
AFAIK Python provides tools for level 3 and above only.
Jul 18 '05 #7
DCK
Peter Hansen wrote:
Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding. I was on some kind of Network course, where teacher said, that telnet
is better then PING. In my work i found this usefull for pinging
network. When i meet with Python, i foud TELNETLIB module and write
simply scheduled script which probe network.
from socket import *
s = socket(AF_INET, SOCK_STREAM)
try:
s.connect((host, port))
print 'host connected'
s.close()
except error:
print 'host not responding'


THX for this advice. In future i will read manual carefully :)

Greetz
Michal DCK Kaczor
Jul 18 '05 #8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2004-01-27T11:11:22Z, "DCK" <dc*@gazeta.pl> writes:
I was on some kind of Network course, where teacher said, that telnet is
better then PING.


Your teacher was on crack. That's like saying that "table lamps are better
than pencil cups". :-)
- --
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAFn/T5sRg+Y0CpvERAq0UAJ9WhPxMY1Um93QwcOLqGHy+0KlcQgCeJ bdW
4o7kvcO5ryEZ8HrSwDy7o9c=
=kPeN
-----END PGP SIGNATURE-----
Jul 18 '05 #9

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

Similar topics

3
by: Adam Flott | last post by:
I'm having some difficulty getting the expect function of telnetlib to capture some data that gets returned from a telnet connection. Python's telnet debug reports this: recv...
4
by: praba kar | last post by:
Dear All, Normally we can send mail using telnet in linux. In the following way telnet Ipaddress 25 mail from: raj@rajkumar.com 250 o.k(response of from commandline) rcpt to: test@oops.co.in...
3
by: Horst Walter | last post by:
What I try to accomplish is to run "telnet.exe" as a process in C#. The C#-code below works with terminating commands, e.g. a "HelloWorld.exe". Since I'd like to communicate with "telnet" the...
2
by: Arne | last post by:
Hello! Task: Connecting to a unix server and getting the directory list . OS: XP Connecting to the server via telnet is no problem. I also want to get the directory list. I know by using...
1
by: luvic.vangool | last post by:
Hi, I am looking for a suitable Ajax Telnet Application. The main reason for this is I have a training company client that needs to allow access to their training systems via completely vanilla...
20
by: valpa | last post by:
I'm a net admin for about 20 unix servers, and I need to frequently telnet on to them and configure them. It is a tiring job to open a xterm and telnet, username, password to each server. Can I...
2
by: b00x | last post by:
Hi, I'm trying to develop a script that I can reuse to run remote commands on multiple UNIX servers via telnet. I've tried various php scripts after googling for a good 5 or so hours, but found...
5
by: anton07 | last post by:
im using suse.. and trying to run telnet service..the service is running but after a while(3-4 days), telnet cant ping anymore.. everything is correctly configured, and nothing is changed in that...
2
by: thamayanthi | last post by:
Hi, The below code is used to connect to the remote machine using Telnet module in perl. use Net::Telnet; use Net::Ping; $telnet = new Net::Telnet (Timeout=>10,Errmode=>'die'); open...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.