- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script help please ..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 12:42 PM
02-26-2002 12:42 PM
I am working on an auditing script to see how many times users log in and fail. I am working with the last,lastb, command and the su.log.
With the last commands I am doing
last | grep -v ftp # this is because there are allot of ftps going on and I am not too intrested in them. And I get output like so:
rleon pts/te Tue Feb 26 14:42 - 14:43 (00:00)
rgagnon pts/tc Tue Feb 26 14:29 still logged in
rleon pts/ta Tue Feb 26 14:28 still logged in
bkirk pts/ta Tue Feb 26 13:28 - 13:30 (00:01)
bconvers pts/te Tue Feb 26 11:18 - 11:40 (00:22)
bkirk pts/tg Tue Feb 26 10:47 - 13:21 (02:34)
How can redirect this output to be more of a port type output? For example
rleon still loged in 1
rleon 1
bkirk 2
bconvers 1
And so on. I have been working with awk but I cant get the right output. I know if I can get the right awk santax that I can fix them all to output right.
Thanks
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 12:53 PM
02-26-2002 12:53 PM
Re: script help please ..
last | grep -v ftp |sort
the default behavior for sort is to sort on the first space-delimited field. You can change this, man sort for more info.
HTH
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 01:55 PM
02-26-2002 01:55 PM
Re: script help please ..
sort -k 6,6 sulog
or with the
last | grep -v ftp | sort
I can sort buy the users. But I still need a final count of the users. But just a list of the users. I need to turn this:
ajohnson pts/ta Tue Feb 26 08:05 - 08:05 (00:00)
rleon pts/ta Tue Feb 26 14:28 - 15:05 (00:36)
rleon pts/tc Tue Feb 26 15:37 - 15:41 (00:04)
rleon pts/tc Tue Feb 26 15:49 still logged in
rleon pts/te Tue Feb 26 14:42 - 14:43 (00:00)
into this:
ajohnson 1
rleon 4
And so on for all the users that come out with the last command.
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 02:03 PM
02-26-2002 02:03 PM
Re: script help please ..
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 02:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 02:06 PM
02-26-2002 02:06 PM
Re: script help please ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 02:14 PM
02-26-2002 02:14 PM
Re: script help please ..
(see attached)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 02:18 PM
02-26-2002 02:18 PM
Re: script help please ..
It's for a trusted system.
#!/bin/sh
SCRIPT=${0##*/}
TODAY=$(date)
TMPFILE=/tmp/$SCRIPT.tmp
LOGFILE=$SCRIPT.log
get_users()
{
cat /etc/passwd | cut -d: -f1 > $TMPFILE
}
check_last_login()
{
while read user ; do
LOCKED=`/usr/lbin/getprpw -m lockout $user | sed 's/lockout=//'`
if [ $LOCKED -ne 0 ] ;
then
DISABLED="LOCKED OUT"
else
DISABLED=""
fi
LASTLOGIN=`/usr/lbin/getprpw -m slogint $user | sed 's/slogint=/'$user' /'`
echo "\n$LASTLOGIN\t$DISABLED"
done
}
get_users
echo "USERNAME LAST LOGIN TIME"
check_last_login < $TMPFILE
rm -rf $TMPFILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 08:55 AM
02-27-2002 08:55 AM
Re: script help please ..
Instead a mere Perl one-liner does this
(might be improvable, since I just hacked it in at the shell prompt)
last|perl -nae '$user{$F[0]}++ unless $F[0] eq "ftp";END{map {printf "%10s%6u\n",$_,$user{$_}} keys %user}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 10:36 AM
02-27-2002 10:36 AM
Re: script help please ..
You might consider this:
#!/usr/bin/sh
last|sort -k1| awk 'NF>1 && $2 !~/ftp/ && $1!~/wtmp/ {
if (FIRST==0) {FIRST=1;USR=$1}
if (USR!=$1) {print USR,"ON="ON,"OFF="OFF;ON=0;OFF=0}
USR=$1
if ($7~/still/) {ON++} else {OFF++}
}'
Regards!
...JRF...