1834324 Members
2795 Online
110066 Solutions
New Discussion

Script

 
SOLVED
Go to solution
M.sureshkumar
Regular Advisor

Script

Hi All,
we need script for the current ftp login users list from "last" command output.
Pls help me.

Thanks & Regards,
Suresh
14 REPLIES 14
Dennis Handly
Acclaimed Contributor

Re: Script

You need to explain better what you want.
Do you want to check which users that last(1) shows were from ftp? What do you mean by "current", who(1) would do that better.
M.sureshkumar
Regular Advisor

Re: Script

Hi

We need to edit the ftp login details only in last command output and put it to file.

Eg:
$ last |grep -i ftp |more
sankar ftp 10.12.22.95 Oct 13 07:42 - 07:43 (00:00)
sankar ftp 10.12.22.95 Oct 11 10:12 - 10:25 (00:13)
sasi ftp 10.13.13.82 Oct 09 15:17 - 15:18 (00:00)
sasi ftp 10.13.13.82 Oct 09 15:13 - 15:17 (00:03)
Note: i need current ftp login users details only.Pls help me.

Regards,
Suresh
Matti_Kurkela
Honored Contributor

Re: Script

last | grep 'ftp .* still logged in$'

MK
MK
M.sureshkumar
Regular Advisor

Re: Script

Hi

How to edit current date(today) ftp login users in last command output.

Regards,
Suresh
Lovro VRES
Advisor
Solution

Re: Script

I think this will help:

last | grep "`date +"%-4.4h%d"`" | more

Regards,
Lovro
Dennis Handly
Acclaimed Contributor

Re: Script

>MK: last | grep 'ftp .* still logged in$'

Since last(1) takes a user name, you can remove that part of the grep.
M.sureshkumar
Regular Advisor

Re: Script

Hi Lovro,

I executed last |grep -i ftp | grep "`date +"%-4.4h%d"`" |more in our server, it displays last 3 years ftp login details not current details.But i need current date and current year ftp login details only.After that i can schedule this script in autommatic for regular basis.
Please help me.

Regards,
Suresh
Johnson Punniyalingam
Honored Contributor

Re: Script

Hi Suresh Kumar,

pls try ,

last |grep ftp |grep -i "'date -u " |more


Thanks,
Johnson
Problems are common to all, but attitude makes the difference
M.sureshkumar
Regular Advisor

Re: Script

No output jhonson

Regards,
Suresh
Johnson Punniyalingam
Honored Contributor

Re: Script

Hi Suresh Kumar,

reason for no output suspecting no ftpusser login or you try by yourself by ftp localhost

than pls try command again,

Thanks,
Johnson
Problems are common to all, but attitude makes the difference
M.sureshkumar
Regular Advisor

Re: Script

Hi Johnson,

last |grep -i ftp |more command output gives 3 ftp user login details
enovia ftp Wed Oct 15 09:38 still logged in
enovia1 ftp Wed Oct 15 09:36 - 09:38 (00:01)
enovia2 ftp Wed Oct 15 09:36 - 09:36 (00:00)

last |grep ftp | grep -i date -u | more - no output

Regards,
Suresh
M.sureshkumar
Regular Advisor

Re: Script

Hi Johnson,

last |grep -i ftp |more command output gives 3 ftp user login details
enovia ftp Wed Oct 15 09:38 still logged in
enovia1 ftp Wed Oct 15 09:36 - 09:38 (00:01)
enovia2 ftp Wed Oct 15 09:36 - 09:36 (00:00)

last |grep ftp |grep -i "'date -u " |more - no output

Regards,
Suresh
Johnson Punniyalingam
Honored Contributor

Re: Script

Hi Suresh Kumar,

FYI,

Lovro VRES : Command works fine for me..

Please see below

$ last |grep -i ftp | grep "`date +"%-4.4h%d"`"
ibmadm1 ftp Wed Oct 15 12:36 - 12:36 (00:00)
ibmadm1 ftp Wed Oct 15 12:14 - 12:14 (00:00)
$ uptime
12:37pm up 43 days, 20:20, 8 users, load
average: 0.22, 0.23, 0.21

Your server uptime should be more than 3 years can you please check you time stamp for your wmtp file

ll /var/adm/wtmp
-rw-rw-r-- 1 adm adm 534420 Oct 15 12:36 /var/adm/wtmp

if the time-stamp of your /var/adm/wtmp is old that's why your able to see the ftp login for last 3 years

man last --> command for more info


Thanks,
Johnson

Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: Script

>But I need current date and current year ftp login details only.

You can't limit it to the current year without advanced AI technology.

MK mentioned how to find ftp still logged on:
last ftp | grep "still logged in"

(Using ftp will give anonymous ftp only. Is that what you want?)

Lovro mentioned how to get the current date:
last | grep "$(date +"%h %d")"

Ah, here is your advanced AI technology:
/usr/sbin/acct/fwtmp -X < /var/adm/wtmps |
grep "ftp.*$(date +"%h %d.*%Y")"