LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2009, 04:52 AM   #1
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Rep: Reputation: 30
bash script for telnet remotehost port


Hi

telnet 122.18x.xxx.23 80 is giving me

Trying 122.18x.xxx.23...
Connected to 122.18x.xxx.23
Escape character is '^]'.

sometimes it gives me connection refused,, i wanted to monitor the same and if there is connection refused or timedout it should update the same in a txt file with timestamp, can anyone help me out please.
 
Old 06-18-2009, 06:02 AM   #2
Trumpen
LQ Newbie
 
Registered: Dec 2008
Location: Italy
Distribution: Debian & Ubuntu
Posts: 11

Rep: Reputation: 0
In these cases I'd rather use netcat:

Code:
if ! netcat -z "$ip" 80; then
      date "+%Y/%m/%d %H:%M:%S $ip " >>/full/path/dead_servers.txt
fi
 
Old 06-18-2009, 09:27 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Trumpen View Post
In these cases I'd rather use netcat:

Code:
if ! netcat -z "$ip" 80; then
      date "+%Y/%m/%d %H:%M:%S $ip " >>/full/path/dead_servers.txt
fi
And on systems I use, the netcat binary is actually 'nc', so:
Code:
if ! nc -z "$ip" 80; then
      date "+%Y/%m/%d %H:%M:%S $ip " >>/full/path/dead_servers.txt
fi
C-kermit can probably be scripted to do this kind of procedure as well.
--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Port Monitoring bash script twantrd Programming 15 01-29-2009 01:59 AM
bash script (telnet problem.) qrshat Programming 6 11-27-2007 10:26 AM
how to port bash script to c++? jaepi Programming 6 05-09-2007 10:36 PM
Why can't I read in data from the serial port using a bash script? tjt Linux - Newbie 1 06-17-2004 01:21 AM
Telnet in a bash script in linux tiger Programming 3 08-01-2001 08:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration