Tuesday, May 31, 2011

Script to populate mails to mail accounts with an attachment and contents in body.

Shell Script for populating mails to mail users - For testing reasons.

while read username
do
for i in {1..25}
do
mutt -s "sample mail $i" -a /root/attachment.log -- $username"@mltech.com" < mailbody.template
done
done < useraccount

useraccount file will contain mail accounts.
mailbody.template file will contain mail body content.
attachment.log file is the attachment file.

Oneliner script for user account & password creation in linux

You need to have root user privileges to run some of the commands in the script needs.

user=openuser;for i in {1..50};do useradd $user$i;pd=abc;echo $user$i$pd |passwd --stdin $user$i;done

This will create user names openuser1, 2 till 50 with password "openuser1abc, openuser2abc, etc.,"