Want to apply this to crontab:
crontab -l > nopass
echo 'ALERT - Found a user without password on:' `hostname` `date` | cat /etc/shadow | awk -F: '($2==""){print $1}' | mail -s "Alert: Found a user without password on `hostname` `who | awk '{print $6}'`" $ADMIN_MAIL >> nopass
crontab nopass
rm nopass
But this long line is not applied. Is it because the structure of the string is wrong or is it because crontab has some kind of limit in characters? Maybe there is a more convenient way to do what I want?
who | awk '{print $6}'
if you have an user with 100 xterm opened it will be give you 100 lines for the same user (that you do not print because is in the 1st field), if it is from console you will have 100 empty lines. Why didn't you put your long line in a multi line sh or bash script and you call it from cron? If you mind, give a look here and even more here...