We help IT Professionals succeed at work.

easy shell scripting question

MaRiOsGR asked
Medium Priority
Last Modified: 2010-04-17
I've made with the help of people here this script to filter the ssh attempts:

cat /var/log/messages | grep "authentication failure;" | gawk -F: '{ print $4 }' > /tmp/ssh.txt
sort /tmp/ssh.txt | uniq > /tmp/sshfinal.txt
cat /tmp/sshfinal.txt | gawk -F"rhost=" '{ split($2, a, " |\r\n"); print a[1]; }' | uniq > /tmp/sshfinal.txt

i've added this line to get it via email after a cron setup.

echo -e "Subject:Firewall\nFrom:Server <senderemail\>\n"`cat /tmp/sshfinal.txt` | /usr/sbin/sendmail myemail

The sshfinal.txt file looks like this:

But ofcourse when I receive the email its like this :

it may sounds stupid but how can I change that ?

I know i could do that if i would use \n at the end of each ip in the sshfinal.txt file, but the file is generated by the script each time so I dont know how to do that.

Watch Question

Most Valuable Expert 2014
Top Expert 2015
(echo -e "Subject:Firewall\nFrom:Server <senderemail\>\n"; cat /tmp/sshfinal.txt) | /usr/sbin/sendmail myemail

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


it was so easy? damn..

thank you veru much.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.