Function to kill the established rsh session


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function to kill the established rsh session
# 1  
Old 06-19-2010
Function to kill the established rsh session

HI
I know that it sounds crazy Smilie
appreciated if any one provided me a solution for my below case , the below script is checking the Database availability on many servers by establishing rsh session ( one by one ) , sometime one of the servers goes down and while this the script taking over 2 min than I got this message :
Code:
  ::ffff: 10.10.109.61: Connection refused
  ./TABSDB_check1[30]: test: argument expected

what i need it is a function to put it in the below shell script to kill the established ( hanged ) rsh session after 20 seconds at least and echo word "Server Down".

(OS : Solaris 10 )
Code:
#!/usr/bin/ksh
while true
do
clear
$NORMAL
echo `date "+%I:%M %p %a %d %b %Y"` 
echo
echo "DataBase Description                 Status " 
echo "-------------------------------------------\c"  
#$GREEN
k=1
cat TABSDB.list|while read A B C D
do
arry1[$k]=$A
arry2[$k]=$B
arry3[$k]=$C
arry4[$k]=$D
k=`expr $k + 1`
done 
##########################
RED="echo \\033[0;31m\c"
NORMAL="echo  \\033[0;39m"
GREEN="echo  \\033[0;32m\c"
BLUE="echo \\033[0;35m" 
n=1
#$GREEN
echo
while [ $n -lt $k ]
do
if [ `rsh ${arry1[$n]} "ps -ef | grep -v grep | grep "${arry3[$n]}"  2>/dev/null|wc -l " ` -gt 0 ] 
then
echo " ${arry4[$n]}`$GREEN` Running `$NORMAL`"  
else 
#$RED
echo " ${arry4[$n]}`$RED` Stopped `$NORMAL`\c"  
#$GREEN
echo
fi
n=`expr $n + 1 `
done 
sleep 15
#sleep 10
done

Moderator's Comments:
Mod Comment Please use code tags, ty

Last edited by bejo4ever; 06-19-2010 at 07:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

kill() function problem in client-server ipc message using 2 FIFOs

I want to have a message send & receive through 2 uni-direction FIFO Flow of data FIFO1 stdin--->parent(client) writefd--->FIFO1-->child(server) readfd FIFO2 child(server) writefd2---->FIFO2--->parent(client) readfd2--->stdout I need to have boundary structed message... (3 Replies)
Discussion started by: ouou
3 Replies

2. Solaris

Kill idle dt session

Hi, i need to kill the idle dt sessions through script, can anyone tell me how to do? RJS (2 Replies)
Discussion started by: rajasekg
2 Replies

3. Solaris

Elegant Solutions to kill telnet/ssh session

We have a generic user account "user1" setup on Solaris 8 that is used by an application. I dont want users to telnet/ssh using this account. Instead if they want to gain access, they must su or sudo to this after logging in with their own ID. My earlier attempts to accomplish this by disabling... (7 Replies)
Discussion started by: boshyd
7 Replies

4. Solaris

How to kill the TCP ESTABLISHED connection in netstat

Hello, Actually there are some bugs in application which does not close the TCP connection to other server though CORBA. We need to kill that ESTABLISHED connections as new connection are not happeneing as the allocated ports were used and showing as ESTABLISHED Is there any... (4 Replies)
Discussion started by: GIC1986
4 Replies

5. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

6. Solaris

kill user session

how do i kill a user session (10 Replies)
Discussion started by: fsmadi
10 Replies

7. UNIX for Dummies Questions & Answers

Script to kill rsh processes running for more than 10 mins

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (3 Replies)
Discussion started by: amitsayshii
3 Replies

8. Shell Programming and Scripting

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

9. UNIX for Advanced & Expert Users

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies
Login or Register to Ask a Question