473,698 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_hos t,tn_port):
try:
tn = telnetlib.Telne t(tn_host,tn_po rt)
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.ar gv[1],sys.argv[2])
else:
print 'Usage: telping.py <host> <port>'

if __name__ == "__main__":
main()
Jul 18 '05 #1
8 4369
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.p l> 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+Y0CpvERAq 0UAJ9WhPxMY1Um9 3QwcOLqGHy+0Klc QgCeJbdW
4o7kvcO5ryEZ8Hr SwDy7o9c=
=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
4491
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 'whoami\n\r\xff\xfc\x01\r\nHi, my name is : Home\r\nHere' IAC WONT 1 recv ' is what I know about myself:\r\nModel: ' recv ' VSX 7000\r\nSerial Number: 822232085C63K\r\nS' recv 'oftware Version: Release 1.0 - August 2001\r'
4
5196
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 250 o.k(response of from commandline) data 354 go ahead(response of from commandline)
3
11659
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 process is still running when I already have to read from the stream. This seems to be the problem, since "myStreamReader.ReadLine()" is waiting for something.
2
4939
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 read_all I can get all the output (starting from the login up to the end). 1. What I look for is the option to get only certain parts of the output. It seems to me that the command "read_sb_data" can do this. The documentation
1
5902
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 browsers, and does not want the trainees to have to install anything, or accept anything, on their machines. My requirements are that it: 1) has a command filter
20
3941
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 do it automatically by python? After that, there have 20 xterm consoles opened and telneted to their corresponding servers. Then I could start to type command in these xterms. Any suggestion appreciate. Much thanks.
2
15777
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 no luck. I've created a script (suprisingly) similar to the on found an old post from 2001...
5
2270
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 period of time.. what can i do to make the telnet active till i want to stop the service?
2
2990
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 (FILE,"C:/start.txt") or die ("Unable to open start.txt"); while(<FILE>)
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
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
9029
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...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4370
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...
1
3050
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
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.