Solved

Automation of telnet

Posted on 2007-03-26
8
417 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…

762 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

23 Experts available now in Live!

Get 1:1 Help Now