Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Automation of telnet

Posted on 2007-03-26
8
Medium Priority
?
451 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 252 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 248 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

604 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