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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to kill hung logins

Status
Not open for further replies.

antix

IS-IT--Management
Jun 4, 2002
26
US
Hello,

This is part of a script from SCO that will not work on AIX any ideas as to why?

cat /tmp/hung_pids | while read line
do
awk '{
if ( $3 == "1" && $6 >= "ttyp0" )
{
{ print $2 } ;
}
if ( $8 == &quot;<defunct>&quot; )
{
{ print $2 } ;
}
}' >> /tmp/hung_pids.kill
done

We deliberately knocked a person out but it will not pick it up. I have more info if needed.

Thanks Scott
 
I presume that the /tmp/hung_pids file is generated from a ps command. What options are used to ps and do they give the same output on SCO & AIX?

Also how are these users logging in, do they use /dev/ttyp devices or /dev/pts? (use who or last to determine this).
 
Here is my PS command:

ps -ef | grep -v &quot;root&quot; | grep -v &quot;lp&quot; | grep -v &quot;nouser&quot; | grep -v &quot;daemon&quot; | grep -v &quot;mmdf&quot; | grep -v &quot;bin&quot; > /tmp/hung_pids

And yes SCO works this perfectly...

And we are trying to kill networked users who are either knocked off or drop off their emulator incorrectly.

Thanks Scott
 
Oh sorry didn't specify.. it was &quot;pts&quot; and that has been changed in the script.
 
Possibly the script is confused by the >= when dealing with strings like &quot;pts/0&quot; or &quot;pts/1&quot;.
If you just want to check to see if it is a pts session then use a substring
ie, change the line:
if ( $3 == &quot;1&quot; && $6 >= &quot;ttyp0&quot; )
to be:
if ( $3 == &quot;1&quot; && substr($6,0,3) == &quot;pts&quot; )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top