Solved

Automation of telnet

Posted on 2007-03-26
8
436 Views
Last Modified: 2013-12-26
Hi,
I've a situation where I'm using KSH (AIX) and need to write a shell script.
From one server(say ServA), I need to check continously for some processes and if some of them are down, then need to bring up the processes from another server (say ServB), need to connect to ServB from ServA thru either telnet or ssh
How do I approach this, first telnet should be done automatically when the trigger occurs & then run another shell script in ServB which will start the processes.

Thanks & Regards
prasen
0
Comment
Question by:prasen120998
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 

Accepted Solution

by:
mwdonovan earned 63 total points
ID: 18805755
Least complicated and most robust method is to have two watchers, one on each machine, and a shared directory on ServB that can be seen from ServA via whatever cross-mount method your admins prefer.

Have the watcher script on ServB run every few minutes or seconds, depending on desired response speed... whatever you do, don't have the watcher cycle continuously. When the ServB watcher finds a desired running process, it touches a file in the shared directory that is named appropriately; such as, critical_process_a_heartbeat.tmp

The watcher on ServA runs and sleeps on a similar schedule. It looks for the presence of the heartbeat file and checks its time-stamp against current time.

If the heartbeat file is not present or the time-stamp is older than a given limit, then the process is assumed to not be running. The ServA watcher removes the shared heartbeat file (if present), and creates a restart file in the shared directory.

The ServB watcher not only looks for running processes, but restart files as well. If it finds critical_process_a_restart, it will do whatever is required to restart the dead process. Make sure a process is not running before attempting a restart, just in case someone beat you to it...

Notice that you haven't messed with telnet or ssh remote calls at all, beyond having your admins set up the shared directory.

Hope this helps :)

mwdonovan

0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 62 total points
ID: 18878210
# for example on ServA:
ssh user@ServB other-shell-script

(assuming that you have setup ssh with keys for user)
0
 
LVL 4

Expert Comment

by:rwaldicott
ID: 19034192
you can do this using some .NET or Java classes

See the TelnetSession and SshSession classes here:

http://www.jscape.com/sshfactory/  (Java)

http://www.jscape.com/sshfactorydotnet/ (.NET)

http://www.jscape.com/telnetfactorydotnet/ (.NET)
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Expert Comment

by:mwdonovan
ID: 19034854
Only if you want it to be overly complex, terribly slow, and indecipherable. Simple shell scripts can do the job faster and cleaner with no dependency on .NET or the complexity of Java. Using either in this situation is a bit like using a nuclear weapon to swat a fly.

Cheers :)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 19038573
if nuclear things are java/.net driven, there's enough time to escape ...
SCNR ;-)
KISS -keep it simple stupid
0
 

Expert Comment

by:mwdonovan
ID: 19040916
Hah - good point... hopefully, the DoD won't use .net or java for deployed tactical systems ;)

Prasen - have you made progress or do you need some skeleton scripts/examples?
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article will show, step by step, how to integrate R code into a R Sweave document
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question