- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to verify the connection to other unix ser...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 12:50 AM
09-07-2009 12:50 AM
Our customer need us to develop some script to verify whether the connection to other unix server is ok or not ?
For Example: Work at server A, then want to use command "telnet server_B 383" to check the connection to server_B 383 is ok,
# telnet 16.173.244.124 383
Trying...
Connected to 16.173.244.124.
Escape character is '^]'.
So i write simple shell script like below :
telnet server_B 383 > telnet.log
I just want to get the output of command "telnet 16.173.244.124 383" to verify whether below keyword is exist or not
"Escape character"
if exist ,then the connection is ok ,otherwish the connection is broken, But when i run this script, it hang at that moment, i think may the script are waiting for my input the user/password.
Does anyone know how to solve it , thanks so much!
Could we set the time out of command telnet ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 01:04 AM
09-07-2009 01:04 AM
Re: How to verify the connection to other unix server by script?
You can use simple ICMP reply to check the other unix servers connectivity.
- Create a script using # ping -c 2
It will ping two times, if response is 100% success , server is reachable, else not.
- Run the script from another server , that never goes down or less downtime, using crontab or background. (&) .
- redirect logs to a log file. and you can put email notification if any server is unreachable.
Hope this helps.
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 03:15 AM
09-07-2009 03:15 AM
Re: How to verify the connection to other unix server by script?
I believe an easy way to check is using ICMP that is:
ping other server and get RC to check if it is ZERO or NOT, thats all. if you want to use telnet check ,I recommend you to write both shell and TCL script , use shell as wrapper..
but due to my environment have lots of different servers I don t have any chance to write a generic TCL macro...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 07:29 AM
09-07-2009 07:29 AM
Re: How to verify the connection to other unix server by script?
Define "the connection". There are many ways
for one system to be connected to another.
"ping" tests low-level IP connectivity, but
it's often blocked by firewalls. A Telnet
script can check the remote system's Telnet
server. A Web browser or wget can check the
remote system's HTTP server. An FTP client
script or wget can check the remote system's
FTP server. And so on. It's a long list,
including rsh/remsh, ssh, and many others.
Are you interested in some particular service
or services (like, say, Telnet)? If so, then
it makes sense to test it or them.
You seem to be trying to connect to port 383,
which, with Google's help, I guess, may be
related to HP's Performance Data Alarm
Manager (about which I know nothing).
> i think may the script are waiting for my
> input the user/password.
That's what Telnet generally does. You can
use a program like "expect" to help script a
Telnet session. Other services may be easier
to test in a simple script. (I use wget on
my VMS system to check on its Web server,
for example.)
However, if you're connecting to port 383,
then you're talking to some server program
about which I know nothing, so I don't know
what it expects you to send. I'd guess that
you don't know, either.
Using Telnet manually to check access to
some arbitrary port makes some sense, but if
you're trying to write a script to check it,
then why not use some real Performance Data
Alarm Manager (or whatever) program/command
to do some real work?
As usual, it might make more sense to
describe the actual problem which you are
trying to solve, rather than asking how to
implement some sub-ideal solution to that
problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 09:35 AM
09-07-2009 09:35 AM
Re: How to verify the connection to other unix server by script?
go to this below links you will find different scripts.
http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1252344730386+28353475&threadId=766322
http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1252344671437+28353475&threadId=960333
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2009 11:04 AM
09-07-2009 11:04 AM
Re: How to verify the connection to other unix server by script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2009 10:12 PM
09-27-2009 10:12 PM
SolutionYou can use EXPECT. This would do the job you asked for.
Take a look at this thread:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=951550
Just an ideea for your script:
---------------------------------
while {1} {
expect -nocase "password*" {
send "$password(login)\r"
} eof {
badhost $host "spawn failed"
break
} timeout {
badhost $host "could not log in (or unrecognized prompt)"
exec kill $pid
expect eof
break
} -re "incorrect|invalid|Denied" {
badhost $host "bad password or login"
exec kill $pid
expect eof
break
} -re $prompt {
set logged_in 1
break
}
}
if (!$logged_in) {
wait
continue
}
-----------------------------------
Best regards from Romania,
Horia Chirculescu.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2009 10:53 PM
09-27-2009 10:53 PM
Re: How to verify the connection to other unix server by script?
> you asked for.
Except that he was trying to test port 383,
not a real Telnet server, so all that user
name and password stuff doesn't fit here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2009 11:12 PM
09-27-2009 11:12 PM
Re: How to verify the connection to other unix server by script?
"Except that he was trying to test port 383,
not a real Telnet server, so all that user
name and password stuff doesn't fit here."
The fact that it test the port 383 have nothing to do with EXPECT.
Chinese Feng could run expect -nocase for the string "Escape character" /whatever his daemon (not important if it is or not a telnetd daemon) listening on the port 383 (also, not important the port no.) replays with.
Best regards from Romania,
Horia Chirculescu
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2009 11:39 PM
09-27-2009 11:39 PM
Re: How to verify the connection to other unix server by script?
Attached is a simple expect script that accomplishes your task.
Kind regards,
Kobylka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2009 02:17 AM
09-28-2009 02:17 AM
Re: How to verify the connection to other unix server by script?
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $host = "";
my $port = "";
my $handle = "";
unless (@ARGV == 2) { die "usage: $0 host port" }
($host, $port) = @ARGV;
$handle = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $host, PeerPort => $port) or die "False";
print "True";
exit;
Or you could test the simple way:
echo " " | telnet host port
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2009 04:36 AM
09-28-2009 04:36 AM
Re: How to verify the connection to other unix server by script?
> the string "Escape character" /whatever his
> daemon (not important if it is or not a
> telnetd daemon) listening on the port 383
> (also, not important the port no.) replays
> with.
How do you know that this (unidentified)
daemon replies with _anything_?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2009 04:44 AM
09-28-2009 04:44 AM
Re: How to verify the connection to other unix server by script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2009 09:28 PM
09-30-2009 09:28 PM
Re: How to verify the connection to other unix server by script?
(Quotation)
Chinese Feng could run expect -nocase for the string "Escape character" /whatever his daemon (not important if it is or not a telnetd daemon) listening on the port 383 (also, not important the port no.) replays with.
(End quotation)
It is not important what this daemon behind the stated port replies (or if it ever replies!). The telnet client will allways (well, at least in most of the situations...) respond with some confirmation string like the one stated by Feng:
(Quotation)
# telnet 16.173.244.124 383
Trying...
Connected to 16.173.244.124.
Escape character is '^]'.
(End quotation)
If the daemon would reply something, Feng would actually continue the script (or ever ignore in the script the first part related to the output from telnet client) - and this situation I was talking about in:
"/whatever..." from the first quotation
My point is that EXPECT is a good solution as would cover all the situations we are talking about.
Best regards from Romania,
Horia Chirculescu
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2009 09:46 PM
09-30-2009 09:46 PM
Re: How to verify the connection to other unix server by script?
And _my_ point is that getting connected to
some daemon doesn't really tell you if it's
working properly. Whether getting connected
is good enough depends on what you really
want to know, and we were never really told
that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2009 10:20 PM
09-30-2009 10:20 PM
Re: How to verify the connection to other unix server by script?
that."
Well, this is how the input data sounds like.
In fact, just by checking connection to one daemon does not mean that the "whole" unix server is "ok" (If I understand right, this was the answer expected by Chinese Feng, not just finding out if some service is running or not on the target system).
There are situations when the server is not responding (from the point of the services that he provide) but still he responds to ping (I mention ping as it was a reffernce to it on other post), or telnet connections get in state "connected" but nothing more...
Best regards from Romania,
Horia Chirculescu
Horia.