auto kill script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting auto kill script
# 1  
Old 09-20-2012
auto kill script

Hi,

I have created a shell script which is used by many users to change their password/unlock, etc., via menu. There is possibility users just close the putty window without proper exit from menu.

I want a solution so that if anybody forgets to stop that session, it should kill automatically itself after x amount of time. Or any point of time if it is waiting for long for user input it should automatically kill the session after x amount of time.

Shell is written in ksh and we are running it on Solaris 10.

Any thoughts??
# 2  
Old 09-20-2012
How the script is invoked? If its invoked directly from command line, the process automatically closes with the session closed.

Are you performing any special rules with the exit? or just exit ?
Better to show the excerpt from the script which is used to close the session.
# 3  
Old 09-20-2012
I have restricted users to login to server so I have put this script into their shell parameter into passwd file. I also have used all traps into script. As soon as user get log in they get menu.

My concern is if script is waiting for user input for x seconds then it should close the session automatically.
# 4  
Old 09-20-2012
If you have one of the common login shells (ksh or bash) you can use the "TMOUT" environment variable.

Have a look at the man page for details.

I hope this helps.

bakunin
# 5  
Old 09-20-2012
I had used TMOUT variable but it works only if it gets shell. In my case when the script runs it waits for user input so this variable doesn't work out.
# 6  
Old 09-20-2012
Try something on these lines:
Code:
echo 'ENTER SOMETHING : '
if read -t 5 var
then
 echo "SOMETHING ($var) WAS ENTERED WITHIN 5 SECONDS"
else
 if (( $? == 1 ))
 then
  echo "NO INPUT... (CTRL-D)?"
 else
  echo "YOU DIDN'T ENTER ANYTHING FOR 5 SECONDS"
 fi
fi

# 7  
Old 09-20-2012
read -t 5 option doesn't work over ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Auto-backup script

hello guys i need a script to automatically backup a whole directory in linux like /var/www and the whole sql db and upload to an ftp server daily (as a cron job) is there something like this? I read about rsync but I don't know if it will suit this. (6 Replies)
Discussion started by: galapagos8000
6 Replies

2. Shell Programming and Scripting

How to provide auto inputs for a sub-script within a script?

Hi All, I am writing a shell script. #!/bin/bash cat /etc/hosts mkdir -p /var/tmp mount 113.123.35.37:/vol/vol615/syb /var/tmp In above script I am trying to add below predefined script/command (/var/tmp/db_tools) This command in turn ask for user input, which will be always option... (17 Replies)
Discussion started by: madhur.baharani
17 Replies

3. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

4. Shell Programming and Scripting

Auto restart script does not work

I have a service that are not 100% stable and stops from time to time. So I have a script that do restart the service if it does not run. This script works win on Ubuntu 9.04 but will not start the service in Ubuntu 10.10 If I run the part that do starts the service from CLI, it starts... (2 Replies)
Discussion started by: Jotne
2 Replies

5. Red Hat

Redhat 5 enterprise auto kill script

hi all do i need to add rc. prefix on the stop script all the time especially on redhat 5 enterprise? like below ln -s /etc/init.d/rc.stopdb2 /etc/rc0.d/K01rc.stopdb2 and on the /etc/rc.local, i need to add this only touch /var/lock/subsys/stopdb2 Is that going to work? thanks... (1 Reply)
Discussion started by: itik
1 Replies

6. HP-UX

Script to auto restart a service

Hi All, May i please know if it is possible to write a script to check the log messages and automatically restart a service if it is failed or it is stopped. Appreciate your suggestions. Thanks in advance. regards, Eajaz (2 Replies)
Discussion started by: ajazshariff
2 Replies

7. Windows & DOS: Issues & Discussions

auto login script

can any one help me for auto login bat file from windows to unix,to check the server daily.. Thanks Mohan (1 Reply)
Discussion started by: mohankasi
1 Replies

8. UNIX for Dummies Questions & Answers

Shell Script to Auto Run PHP Script

Hello All! I am looking to build a monitoring script. The script should always run as a system service of some type and should always check that a PHP script is running. Maybe there is a way to assign a PHP script to a certain PID so that the monitor script that check for the PID in top... (4 Replies)
Discussion started by: elDeuce
4 Replies

9. Shell Programming and Scripting

Auto Alias Script

Hi All, as you can guess, I'm a newb here, and to shell scripting. I use Linux(CentOS) at home and want to get into scritping. I was creating some aliases on a Laptop the other day, and thought, god this is tedious, and then I thought, heck, why not use it as a 1st script project. Please see... (3 Replies)
Discussion started by: coolboarderguy
3 Replies
Login or Register to Ask a Question