Need help with this challenging code....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with this challenging code....
# 1  
Old 01-19-2009
Need help in writing a timeout for ssh comands?

Hello All,

I am new to this forum, and the reason I came here is to seek solution from the experts.

I have written following wrapper script, it was running fine from past couple of months, until last week.
When one of the function in the script which suppose to login through ssh to the external server and run the script to start/stop the tibco or http get hanged. The script hanged till 14 hours when it comes to our notice that nothing is running.

Now my problem is that when the script executes the external scripts on which I donot have any control through ssh. It looses the control, and become fully dependent on the external script to pass the control back to my script where I can decide that the external command or scipt ran successfully or not.

Can there be a way by which my script be able to do the following?

1- Able to identify if the external scripts or commands hangs or taking longer time then expected?
2- Able to kill the external commands or script plus all the subsequent scripts and report an error?
3- OR can I built the timeout for each function?

Any help will be highly appreciated as I have tried everything but my Unix skills aren't that good that I could resolve this issue on my own.

Regards
Tajdar




F_STOP_HTTP()
{
# This stops the HTTP server for CRM so no one can log on.
set -x
log_message "Stopping the CRM HTTP server on ${HTTP_HOST}."


su - jxadmin -c "ssh ${HTTP_HOST} '/opt/app/IBMIHS/bin/apachectl -d /opt/app/IBMIHS/ -f /opt/app/IBMIHS/conf/httpd.conf.was${ENV}.ChordiantServerCobal -k stop; echo $?'"

if [[ $? -eq 0 ]]
then
log_message "Success: HTTP server stopped successfully."
else
log_message "Error: HTTP server cannot stop, exiting. Please check the detail Logs."

mail_error
echo `date`": Script Failed Exiting."
exit 1;
fi

}
# ----------------------------------------------------------
# MAIN BIT
# ----------------------------------------------------------

F_STOP_HTTP

## End of Script...
echo `date`": Script Completed Successfully."
exit 0;

Last edited by tajdar; 01-20-2009 at 06:57 AM.. Reason: To make it more elaborative
# 2  
Old 02-03-2009
# 3  
Old 02-03-2009
I posted a solution to a similar problem here:

https://www.unix.com/shell-programmin...#post302283088
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Challenging scenario

Hi, My input file contains 1,2 2,4 3,6 4,9 9,10 My expected output is 1,10 2,10 3,6 4,1 9,10 (6 Replies)
Discussion started by: pandeesh
6 Replies

2. Shell Programming and Scripting

simple but challenging ignore case

Folks - I found this code on the forums to extract a paragraph for a matching pattern but I don't know how to make it ignore case. grep "-ip" is not an option for me as I am on SUSE LINUX. Thanks for ur help. I run this script as below: grep_para.ksh sqlstate < logfile "The end result... (2 Replies)
Discussion started by: beowulfkid
2 Replies

3. Shell Programming and Scripting

Challenging Awk array problem

Hi, I rather have a very complicated awk problem here, at least to me. I have two files. File 1: 607 687 174 0 0 chr1 3000001 3000156 -194195276 - L1_Mur2 LINE L1 -4310 1567 1413 1 607 917 214 114 45 chr1 3000237 ... (19 Replies)
Discussion started by: polsum
19 Replies

4. UNIX for Advanced & Expert Users

Very Challenging :Copy files in Multiple Threads

Hello all, I asked this in the basic Unix forum got no answer since one week. So I believe this is an advanced level question hence posting it here. Any suggestions welcome. I have a directory of files of varying sizes. I want to copy all these files in n number of threads to... (2 Replies)
Discussion started by: samoo
2 Replies

5. Shell Programming and Scripting

Very Challenging Problem. Please read fully.

Hi, This is the Third thread i'm putting here for the same problem. :( Actually, i'm trying a script like this.. but its taking a long time.. about 3 days to complete fully.. #!/bin/ksh if then exit 1 fi while read i do while read j do field7=`echo $j|cut -d "|"... (12 Replies)
Discussion started by: RRVARMA
12 Replies

6. Programming

A challenging problem involving symbolic links.

Hello, I'm working on an application that bridges together several applications involved in creating a video workflow for editing with digital cinema cameras. The main platform is MacOSX. Because of the nature of some of the utilities for working with this video footage I must spoof filenames... (2 Replies)
Discussion started by: ibloom
2 Replies

7. Shell Programming and Scripting

Challenging!! Help needed

Hi, I have a script xyz.ksh which accpets two parameters the format of first one is :X_TABLENAME_Y and second one is a digit. I can extract a table name from that parameter and store it in a variable var_tblnm, so if i pass a parameter X_TABLE1_Y the value in var_tblenm is "TABLE1" now i have... (1 Reply)
Discussion started by: hcdiss
1 Replies

8. Shell Programming and Scripting

Challenging Compare and validate question -- plus speed.

I have a tab delimited HUGE file (13 million records) with Detail, Metadata and Summary records. Sample File looks like this M BESTWESTERN 4 ACTIVITY_CNT_L12 A 3 M AIRTRAN 4 ACTIVITY_CNT_L12 A 3 D BESTWESTERN FIRSTNAME LASTNAME 209 N SANBORN AVE D BESTWESTERN FIRSTNAME LASTNAME 6997... (25 Replies)
Discussion started by: madhunk
25 Replies

9. UNIX for Dummies Questions & Answers

A Challenging situation for the MODERATORS

Well, I hope this way you will respond to my inquiries. I have 4 unix servers,with static ips (though i dont think this is an issue)....i can telnet and rlogin from one to the other....if i FTP from on et othe other and try to execute : cd /user return /user : no such file or... (1 Reply)
Discussion started by: BAM
1 Replies

10. UNIX for Advanced & Expert Users

Very Challenging Question! Need help bad!

I am in desperate need of an answer to this question. I have looked everywhere (even the man pages) and found very little. Solaris has the concept of "plumbing" a network interface. What does this mean? I would be really greatful to whoever could help me answer this question. I am so... (1 Reply)
Discussion started by: Sparticus007
1 Replies
Login or Register to Ask a Question