A few other minor comments:
1/ "
It is not working" is a very poor problem description and the best possible answer to that is "
Fix it". You need to be more specific.
How do you run the script? Manually,
at,
cron, ... ?
What is the result? Nothing happens, you get error messages, the mail is empty, the script selects wrong accounts,... ?
What shell are you using?
If you don't run the script manually from terminal, redirect its
stdout and
stderr to files.
If you use
cron, make sure you either use full paths for all commands used or set the
PATH variable as necessary.
2/ all the
cats and
echos in your script are useless.
Instead of
Code:
cat /etc/shadow | cut -d: -f1,8
you can just use
Code:
cut -d: -f1,8 /etc/shadow
3/ instead of the
for loop and reading the file
n+1 times, a
while read loop would be much more convenient:
Code:
while read -r username userexp; do
...
done </tmp/expirelist.txt