Solved

Automation of telnet

Posted on 2007-03-26
8
425 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now