Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re: script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I wrote this script to logoff idle users but having a bit of a problem. Can someone look at this please.

#!/bin/sh




who -u | grep -v 'dtlocal' | nawk '{printf("%10s %10s %10s %\n",$1,$6,$7)}' > my

cat my | nawk '{printf("%10s %10s %10s %\n",$1,$2,$3)}' | grep '[2-9][5-9]*:[0-9][0-9]' > myfile

for id in `cat myfile | nawk '{print $1, $2, $3}'`
do

echo "you have been idle for 25 minutes" | write $id > lastime

done

for i in `cat lastime | nawk '{print $1, $2, $3}'`
do

echo "You are now being logged off" | write $i
kill -9 $i

done
 

who -u | grep -v 'dtlocal' | nawk '{printf("%10s %10s %10s %\n",$1,$6,$7)}' > my

#this line gets the user ID process ID and time they have #been idle. It also greps out dtlocal because this is the session the users has when they logon to a sun box. EX: They logon to a CDE (x windows)environment and dtlocal is that environment. I do not want to kill that session because that will cascade down and kill active terminals also. I place all this info to a file called my. I then cat it out to grep for users who have been logged on for 25 minutes or more. I place it in a file called myfile. I then run a for loop with the users who were logged on for 25 minutes. After that I need to add a sleep command for 300 seconds and it will run the for loop again for users in the file lastime that will log the users off.
 
Great. I understand what you are trying to do,
but please explain your problem.
I imagine the script is not presently doing what
you want it to. Do you get standard out or error
back when you run the script? Can you elaborate?
Once I know the problem with your current script,
I can attempt to provide you with a solution :)

Robert Robert G. Jordan

Robert@JORDAN200.com
Unix Admin, United Airlines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top