Sponsored Content
Top Forums Shell Programming and Scripting Script to AutoKill PIDs of LOGED in Active User Post 302147264 by aafflatoon on Monday 26th of November 2007 05:48:15 AM
Old 11-26-2007
Question Script to AutoKill PIDs of LOGED in Active User

Smilie Hi
i am trying to make a script through which i can get the total number of User and their PID after that kill all Users except the one by which i am currently logged in. (i m using SCO UNIX 5.06)

# id of current usre < total number of current user
USR=`who -u |wc -l`

# id of current user
IAM=`who -u -m |cut -b 43-49 |cut -d " " -f1,2,3,4,5`

# name of current user
IM=`who am i | cut -d" " -f1`

# Process ids of all users
PUID=who -u |grep $IM$ |cut -b 43-49 |cut -d " " -f1,2,3,4,5

# Icremental variable

KILPID=0

# This loop will run until the KLPID VAR not equal to the number of user.
while test ${KILPID} -le $USR
do
if [ $IAM != $PUID]
then
kill -9 $PUID
fi
KILPID=`expr ${KILPID} + 1`
done

Last edited by aafflatoon; 11-27-2007 at 01:38 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to count unique number of user loged in

Hi all, I am taking my first course in unix and having some problems. I would line to create a scrip that does the following: 1) will tell me the number of users logged in. If a user is logged more than once just count it only ones. 2) want to be able to display the number of users that... (1 Reply)
Discussion started by: elchalateco
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Then user who loged in befor 5 minutes

hi i am a student, i want to know how to display the users who loged in before 5 minutes, in uinx pls reply me immediately (0 Replies)
Discussion started by: roshni
0 Replies

3. Shell Programming and Scripting

users who loged within 5 minutes

Hi i want to display the users who loged in within 5 minutes in unix by roshni (3 Replies)
Discussion started by: roshni
3 Replies

4. Shell Programming and Scripting

Shell Script for PIDs

I am trying to write a Shell script wherein the shell needs to read a list of PID in the File $stat/bin/Process and compare it to the PID of the processes running on a server. Also the script should return KO(not OK) with corresponding label :- a) When an environmental variable not... (2 Replies)
Discussion started by: marconi
2 Replies

5. AIX

command to kill all loged in users

Guy's I'm looking for command to kill all the loged in users in AIX server Is there specific command can help us to kill any loged in users I have this command who -u it'll show me the process ID of all the users but I want command to kill all the users including to root without... (1 Reply)
Discussion started by: Mr.AIX
1 Replies

6. Homework & Coursework Questions

script to write PIDs to a file

script to write PIDs to a file Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: write a script that writes the PID of 2 different processes to a file every... (1 Reply)
Discussion started by: navlelo
1 Replies

7. Solaris

Configure Solaris to accept Active Directory user logins

Is it possible to configure a Solaris server to authenticate users against an Active Directory server when logging in via ssh? I've seen some docs out there, I've followed their instructions, but it does not work. And I'm beginning to wonder if it is possible or even supported by Oracle. The... (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

8. Shell Programming and Scripting

Active User List Script

Hello guys ! I tried a script to list all the active users in the current server in AIX who | grep '^user' this displays the entire line ... All I need is only the user list I found a command for linux using grep -o word grep -o was not recognized in AIX Can you guys help me out ? Use... (2 Replies)
Discussion started by: varun aravinth
2 Replies

9. UNIX for Beginners Questions & Answers

Find number of ACTIVE SSH putty sessions, excluding where the user hopped on to a diff server

Hi - If iam logged on to server A, on 4 putty windows using SSH ... and out of these 4 logged-in sessions, in one of the sessions if i did SSH from server A to server B; i would now have 4 putty windows sessions ... of which 3 are actively logged on to Server A while 1 putty window is actively... (2 Replies)
Discussion started by: i4ismail
2 Replies
Test::Script(3) 					User Contributed Perl Documentation					   Test::Script(3)

NAME
Test::Script - Basic cross-platform tests for scripts DESCRIPTION
The intent of this module is to provide a series of basic tests for 80% of the testing you will need to do for scripts in the script (or bin as is also commonly used) paths of your Perl distribution. Further, it aims to provide this functionality with perfect platform-compatibility, and in a way that is as unobtrusive as possible. That is, if the program works on a platform, then Test::Script should always work on that platform as well. Anything less than 100% is considered unacceptable. In doing so, it is hoped that Test::Script can become a module that you can safely make a dependency of all your modules, without risking that your module won't on some platform because of the dependency. Where a clash exists between wanting more functionality and maintaining platform safety, this module will err on the side of platform safety. FUNCTIONS
script_compiles script_compiles( 'script/foo.pl', 'Main script compiles' ); The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without error. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. Note also that the test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. script_runs script_runs( 'script/foo.pl', 'Main script runs' ); The "script_runs" test executes the script with "perl script.pl" and checks that it returns success. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. The test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. SUPPORT
All bugs should be filed via the bug tracker at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script> For other issues, or commercial enhancement and support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
prove, <http://ali.as/> COPYRIGHT
Copyright 2006 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2009-11-23 Test::Script(3)
All times are GMT -4. The time now is 09:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy