Sendmail script passing in a file as message. File have filename format test.hostname.network
#!/bin/bash
mailserver=’test@test.com’
for f in $*
do
m=$( echo $f | cut -d. -f2 )
mail -s “XML file from $m” $mailserver < $f
done
You execute the script as such
./sample_script.sh filename
./sample_script.sh test* # execute for all files begin with test in directory