- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to verify the connection to other unix server ...
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
Discussions
Discussions
Forums
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
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