Error in executing ksh from Windows

Hi All,

I wrote a script to send a mail if a particular logfile did not get updated since 5 mins. Here is the Script.

log=`date +%e_%b_%Y`.log # returns todays logfile
x=`date -r $log` # returns last modification time of the Log file
h1=`expr substr "$x" 12 2`
m1=`expr substr "$x" 15 2`
s1=`expr substr "$x" 18 2`
y=`date` # returns current timestamp
h2=`expr substr "$y" 12 2`
m2=`expr substr "$y" 15 2`
s2=`expr substr "$y" 18 2`
typeset -i sec hh mm ss
# to calculate the time difference
let sec=$(echo "$h2*3600+$m2*60+$s2-$h1*3600+$m1*60+$s1)"|bc)
if [ $sec -gt 300 ]; # send mail if the log is not updated since 5 mins
then
echo "Service has stopped.Restart" | mail -s "Restart Service" mailid
fi

The Script got executed successfully in Unix.
The issue is I have to execute the Script from Windows but am getting errors.
Not able to use mail, bc, set commands.
Please help me out...
Thanks in advance!
-Anne

You need to install something like Cygwin or MKS Tools.

Hi,

The MKS Tool does not contain mail.exe.
Is there any other way for me to send a mail?

-Neha

Try "smtpmail". See MKS Knowledge Base

I don't know what options there are for smtpmail, but it probably expects a hostname as the SMTP server that processes your mail.

I have now installed Cygwin. But I get Command not found error for Commands like date and mail... Is there any problem with the Installation???

Why didn't you try MKS' smtpmail command?

I have no idea how to do mail with cygwin. Though, it should have "date"