Sponsored Content
Top Forums Shell Programming and Scripting Problems in analysing SSH LOG users & time Post 302899164 by gacanepa on Sunday 27th of April 2014 11:02:48 PM
Old 04-28-2014
You did not mention your operating system and shell, so I am assuming Linux and bash here. Please note that under different OS and/or shell, you may need to tweak the commands a little:
#1)
Code:
gacanepa@debian $ cat logtest.txt | sort -uk1,1 | cut -f1,3
cc1     swapnil-inspiron
cc2     swapnil-inspiron
cc3     172.27.23.49
cc4     swapnil-inspiron
cc5     swapnil-inspiron
cc6     172.27.23.46
cc7     172.27.23.116
cc8     172.27.23.49
swapnil     :0
gacanepa@debian $ cat logtest.txt | sort -uk1,1 | cut -f1,3 | wc -l
9
gacanepa@debian $

As to #2, when you say "particular time" do you mean a fixed date and time, like Apr 21 18:46?
Assuming that you want to filter by month and day, you can do something like this:
Code:
gacanepa@debian $ cat logtest.txt | awk '/Apr/ && /24/'
cc7     pts/5     172.27.23.246        Mon    Apr    21    18:45    -    18:46    (00:00)     
swapnil     pts/4     172.27.23.125        Thu    Apr    24    01:00    -    01:09    (00:03)     
cc4     pts/3     172.27.23.131        Thu    Apr    24    01:02    -    01:05    (00:03)     
cc7     pts/3     172.27.23.116        Thu    Apr    24    01:03    -    01:03    (00:00)     
swapnil     pts/4     172.27.23.125        Thu    Apr    24    01:05    -    01:08    (00:03)
cc5     pts/5     172.27.23.19        Wed    Apr    24    01:09    -    01:10    (00:01)
cc6     pts/3     172.27.23.131        Wed    Apr    24    13:42    -    13:42    (00:00)     
cc4     pts/3     172.27.23.131        Wed    Apr    24    13:42    -    13:43    (00:01)     
cc7     pts/3     172.27.23.116        Wed    Apr    24    13:43    -    13:43    (00:00)     
cc1     pts/3     172.27.23.116        Wed    Apr    24    13:43    -    13:43    (00:00)     
cc8     pts/3     172.27.23.116        Wed    Apr    24    13:43    -    13:43    (00:00)     
swapnil     pts/3     172.27.23.116        Wed    Apr    24    13:44    -    13:47    (00:03)
cc3     pts/4     172.27.23.131        Wed    Apr    24    13:44    -    13:47    (00:03)
cc7     pts/5     172.27.23.246        Wed    Apr    24    13:45    -    13:46    (00:00)     
cc5     pts/3     172.27.23.123        Wed    Apr    24    13:46    -    13:47    (00:01)
swapnil     pts/3     172.27.23.116        Wed    Apr    24    13:44    -    13:47    (00:03)
cc3     pts/4     172.27.23.131        Wed    Apr    24    13:44    -    13:47    (00:03)
cc7     pts/5     172.27.23.246        Wed    Apr    24    13:45    -    13:46    (00:00)     
cc5     pts/3     172.27.23.123        Wed    Apr    24    13:46    -    13:55    (00:09)
gacanepa@debian $ cat logtest.txt | awk '/Apr/ && /24/' | wc -l
19
gacanepa@debian $

Hope you find this useful. Let us know if you need further help with #3.
Best regards.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

log users real time

hi.... how i can configurator a log file on real time....on unix solaris.... thanks a lot.... Best Regards... (3 Replies)
Discussion started by: chanfle
3 Replies

2. Solaris

OS Problems -no DNS & SSH not working

I just installed Solaris 6/10 without any problems but I didn't connect the network cable when I installed it. Here are my problems: -I can access webpages using IP addrsses but not with domain names -ssh is installed but it is not running ('ps -e | grep sshd' didn't show it) I have been... (4 Replies)
Discussion started by: kungpow
4 Replies

3. UNIX for Advanced & Expert Users

Analysing truss log

I am facing the following issue when using db2. The JDBC prepared statement command is sending an incorrect value to the database for search. I did a truss on the app and here is the log. I want to know what is the value that is getting passed. is it possible. 26867/68: send(62,... (2 Replies)
Discussion started by: buytamil
2 Replies

4. UNIX for Dummies Questions & Answers

Help analysing progress of a log file

Is it possible to track the progress of a job (informatica) by analysing the progress of it's log file ? I have a long running job, and no way of tracking how far allong it is. Thanks. (4 Replies)
Discussion started by: cosmos328is
4 Replies

5. UNIX for Dummies Questions & Answers

Analysing Log Files?

I'm not sure if this query is relevant to this forum but here goes anyways... I want analyse log files that do not appear to be of standard format. I have tried using Analog but cannot config it to read the files. Does anyone have any advice on working with log files taken from a Unix... (6 Replies)
Discussion started by: Sepia
6 Replies

6. Shell Programming and Scripting

How to list Commands used by users & with time stamp

hi, Do anybody know, how to list out all the commands & scripts used by the user & root along with the timestamps under ksh & csh shells. Thanks in advance Regards BS (1 Reply)
Discussion started by: raghunsi
1 Replies

7. Shell Programming and Scripting

Monitoring a users log in time?

how do i start with this guys? Sample run: $ LOGTIME it2015678 <enter> User it2015678 is CRUZ Tommy H And has logged on to the system for: 8 hours 12 minutes from the time this script was run. (1 Reply)
Discussion started by: skypigeon
1 Replies

8. Shell Programming and Scripting

Specified log in time for users

I have this task : Check the logintime.txt every minute to only allow user to log in at the specified time. logintime.txt has the following content: USER TIME_START TIME_STOP Example: john 17:00 18:00 My idea is locking the user at the TIME_STOP and unlocking at the TIME_START while... (4 Replies)
Discussion started by: muffle
4 Replies

9. Homework & Coursework Questions

Sort current logged in users by log in time (supposedly to be very easy but I'm missing something)

1. The problem statement, all variables and given/known data: Show all users who are currently logged in, sorted from earliest to latest log in time. The log in time includes the month, day, and time. 2. Relevant commands, code, scripts, algorithms: finger, who, sort, pipe, head, tail, ... (8 Replies)
Discussion started by: vtmd
8 Replies
PTS_SOURCE(1)						       AFS Command Reference						     PTS_SOURCE(1)

NAME
pts_source - Read pts commands from a file SYNOPSIS
pts source [-file] <file name> [-cell] <cell name> [-noauth] [-localauth] [-force] pts so [-f] <file name> [-c] <cell name> [-n] [-l] [-f] DESCRIPTION
The pts source runs commands from a file as if they were typed in pts interactive mode. The command can be run from the command line or interactively. CAUTIONS
Prior to OpenAFS 1.4.5 and OpenAFS 1.5.23, the pts source command was only available on Unix or Linux and when OpenAFS was compiled with the supergroups option (disabled by default). As of OpenAFS 1.4.5 and 1.5.23, it is always available. OPTIONS
pts source takes the following options: -cell <cell name> Names the cell in which to run the command. For more details, see pts(1). -force Enables the command to continue executing as far as possible when errors or other problems occur, rather than halting execution at the first error. -help Prints the online help for this command. All other valid options are ignored. -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. Do not combine this flag with the -cell or -noauth options. For more details, see pts(1). -noauth Assigns the unprivileged identity anonymous to the issuer. For more details, see pts(1). OUTPUT
This command shows the output of each command in the file as if it were run normally. EXAMPLES
Here is an example of using pts source in a pts interactive session: % echo examine admin > /tmp/commands.txt % pts interactive pts> source /tmp/commands.txt Name: admin, id: 1, owner: system:administrators, creator: anonymous, membership: 2, flags: S----, group quota: 20. pts> quit % SEE ALSO
pts(1), pts_interactive(1), pts_quit(1), pts_sleep(1) COPYRIGHT
Copyright 2007 Jason Edgecombe <jason@rampaginggeek.com> This documentation is covered by the BSD License as written in the doc/LICENSE file. This man page was written by Jason Edgecombe for OpenAFS. OpenAFS 2014-04-08 PTS_SOURCE(1)
All times are GMT -4. The time now is 04:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy