Created
October 12, 2017 01:06
-
-
Save oldkingcone/43460ddbeef137755005378e3479684d to your computer and use it in GitHub Desktop.
Returns user at run time, will log into seperate file and leave human readable date/time with real username and logged in username. Add line ' perl runuser.pl' to your bashrc file to have it run upon TTY/Shell interaction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/tmp/env perl | |
| use strict; | |
| use 5.010; | |
| my $user = $ENV{USER}; | |
| my $logname = $ENV{LOGNAME}; | |
| my $file_directory = "./ranby.txt"; | |
| # my $second_log = "./second.txt"; | |
| my $filename = "ranby.txt"; | |
| # my $second = "second.txt"; | |
| my $timestamp = localtime(time); | |
| # my $path = shift || '/'; | |
| # traverse($path); | |
| # sub traverse { | |
| # my @queue = @_; | |
| #while (@queue) { | |
| # my $thing = shift @queue; | |
| #say $thing; | |
| #next if not -d $thing; | |
| #opendir my $dh, $thing or die; | |
| #while (my $sub = readdir $dh) { | |
| #next if $sub eq '.' or $sub eq '..'; | |
| #push @queue, "$thing/$sub"; | |
| # } | |
| #closedir $dh; | |
| #} | |
| #return; | |
| #} | |
| open(my $filename, ">>", $file_directory) || die "cant open $file_directory: $!"; | |
| binmode($filename); | |
| print $filename "$timestamp, by $user, on $logname\n"; | |
| close($filename) || die "cant close $file_directory: $! "; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment