Email Command Error

Hi ,

i am very new unix i need a script which should check for the size of the file and if it is greater than zero ,than i have copy the contain of the file (the file we have checked the size) as body .

Thanks
Anuddep

#!/bin/somesh
# arg 1 is the filename
SM="/usr/lib/sendmail -t -i "
fname="$1"
[ "$fname" = "" ] && echo "usage:$0 file" >&2 && exit 2

# test size of file using -s = size > 0
# -f test only file, size 0 is also true
[ ! -s "$fname" ] && exit 1

$SM <<EOF
From: myemail@mydomain
To: someemail@somedomain
Subject: File $fname include something

$(<$fname)


-myname-


EOF

@kshji ,

kindly can you please explain the script

FILE=$1                                                         # Accept file name as argument.

[[ -s "$FILE" ]] && mailx -s "Subject" user@host.com < $FILE    # Check file size if > 0, then send mail

I prefer and recommend mailx. I hope you don't need further explanation of bipinajith's script.