Nandakumar
Content Network

You are not logged in.
Click here to login.

Some part of this library is not public. You must register to get exclusive access. If you are already registered, click here to login.


Shell Programming >> 2017

Login Status Using Shell Script

By | | License: proprietary


Code
#!/bin/sh

echo -n "Current date and time     : "
date

echo -n "Number of logged-in users : "
echo $(last | grep -c "still logged in")

echo -n "Terminal name             : "
tty

echo -n "Last login date and time in this terminal:"
echo "$(last $(tty) -F)" | awk '{ print $3 " " $4 " " $5 " " $7 " " $6 }'

Keywords (click to browse): login login-status last-command tty terminal log date time shell sh bash linux gnu unix script programming command-line

Login Status Using Shell Script | Nandakumar Content Network
Copyright © 2015, 2016, 2017 Nandakumar Edamana.