#!/usr/bin/ksh

#-------------------------------------------------
#emails any file 
#syntax: mail_file filename subject_line email_address
# $1 = file to mail
# $2 = subject line
# $3 = email address
#-----------------------------------------------
# set some defaults
#-----------------------------------------------
#--------------------------------
#set environment variables
#--------------------------------
#. $HOME/.idlspm/.global.ksh
. $WFU_PATH/global.site.ksh

cmd=mailx 
#---------------------------------------------------
#you really need to test if mailserver OS is Linux
#---------------------------------------------------
mail_os=$OS

if test $rsh_flag -eq 1
	then mail_os=`rsh $mailserver uname`
fi

if test $mail_os = Linux
	then cmd=mail
fi
email_address=$3
if test $# -gt 3
	then email_address=$4
fi


#------------------
#mail the batchlog
#------------------
if test $mail_flag -eq 1
	then
	if test $rsh_flag -eq 0 
		then
		sendmail=`$cmd  -s  $2 $email_address<$1`
	fi
	if test $rsh_flag -eq 1 
		then sendmail=`rsh $mailserver $cmd -s $2 $email_address<$1`
	fi
	#echo $sendmail
fi

exit

