#!/bin/sh ## ## NAUTILUS ## SCRIPT: 00_anyfile_SHOW_LAST-LOGINS_from_var_logs_wtmp_and_btmp.sh ## ## PURPOSE: Lists the log files /var/log/wtmp and /var/log/btmp ## via the 'last -F' command. ## ## METHOD: The 'last -F' list is put in a temporary file which is shown ## in a text-viewer/editor of the user's choice. ## ## HOW TO USE: In Nautilus, select ANY file in ANY directory. ## Then right-click and choose this script to run (name above). ## ######################################################################## ## Created: 2010may04 ## Changed: 2011may02 Added $USER to a temp filename. ## Changed: 2011may11 Get 'nautilus-scripts' directory via an include script. ## Changed: 2012may11 Changed script name in comments above and touched up ## the comments. Changed some indenting below. ####################################################################### ## FOR TESTING: (show statements as they execute) # set -x ################################################################ ## Prep a temporary filename, to hold the list of filenames. ## We put the outlist file in /tmp, in case the user ## does not have write-permission in the current directory, ## and because the output of 'last' does not, usually, ## have a direct relation to the current directory. ################################################################ OUTLIST="/tmp/${USER}_list_var_log_last_logins.lis" if test -f "$OUTLIST" then rm -f "$OUTLIST" fi ############################ ## Make HEADER for the list. ############################ THISHOST=`hostname` echo "\ ................ `date '+%Y %b %d %a %T%p %Z'` ...................... List of 'last logins' --- on host: $THISHOST Some more information is at the bottom of this list. ------------------------------------------------------------------------------ " > "$OUTLIST" ################################################ ## Use 'last' to make the main part of the list. ################################################ echo " #### last -F : #### " >> "$OUTLIST" last -F >> "$OUTLIST" ############################### ## Make a TRAILER for the list. ############################### SCRIPT_BASENAME=`basename $0` SCRIPT_DIRNAME=`dirname $0` echo " ------------------------------------------------------------------------------ The list above was generated by the script $SCRIPT_BASENAME in directory $SCRIPT_DIRNAME The list was created with the 'last -F' command. If you want to change the output of this script, you can simply edit the script. ------------------------------------------------------------------------------ FOR MORE INFO ON OUTPUT OF 'last': You can type 'man last' in a terminal to see details on how the program can be used. ('man' stands for Manual. It gives you the user manual for the command/utility.) You can type 'man man' at a shell prompt to see a description of the 'man' command. Or use the 'show_manhelp_4topic' Nautilus script in the 'LinuxHELPS' group of Nautilus scripts. Enter 'last' at the prompt for a command/topic. --- The 'last' command lists the contents of log files /var/log/wtmp and /var/log/btmp --- which hold information on the recent logins to this host. ******* END OF LIST of the 'last' output on host $THISHOST ******* " >> "$OUTLIST" ################################################# ## Show the 'last' log file(s) --- wtmp and btmp. ################################################ ## . $HOME/.gnome2/nautilus-scripts/.set_VIEWERvars.shi . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi . $DIR_NautilusScripts/.set_VIEWERvars.shi $TXTVIEWER "$OUTLIST"