Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 30
bash script for telnet remotehost port


telnet 80 is giving me

Connected to
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, 05:02 AM   #2
LQ Newbie
Registered: Dec 2008
Location: Italy
Distribution: Debian & Ubuntu
Posts: 11

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

if ! netcat -z "$ip" 80; then
      date "+%Y/%m/%d %H:%M:%S $ip " >>/full/path/dead_servers.txt
Old 06-18-2009, 08:27 AM   #3
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
Originally Posted by Trumpen View Post
In these cases I'd rather use netcat:

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


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 12:59 AM
bash script (telnet problem.) qrshat Programming 6 11-27-2007 09:26 AM
how to port bash script to c++? jaepi Programming 6 05-09-2007 09:36 PM
Why can't I read in data from the serial port using a bash script? tjt Linux - Newbie 1 06-17-2004 12:21 AM
Telnet in a bash script in linux tiger Programming 3 08-01-2001 07:43 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:13 PM.

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