I'm attempting to create a Perl script that will:
Take the contents of the usernames.tmp file
(usernames.tmp is created from an awk one-liner ran against /etc/passwd)
Take one line at a time and pass it to the su command as a users name.
This should go on until there is no more name to process
However there is one tiny problem, this is my first exposure to
Perl scripting! And I have no idea how to do this. The code below
is my full heated attempt at clobbering together code found around
open (USRLIST, "</tmp/usernames.tmp") || die ("die statement");
defined $USERS = (<USRLIST>);
foreach $NAME (@$USERS)
exec "su - $NAME;cd;/path/to/script2";
Any SOLID pointers, references to functions/methodologies... would
be a real treat!!
Thanks in advance!