I am executing the below in telnet
#!/usr/bin/ksh
File1=simple.txt # The file to check
LogFile=simple.log # The log file
DelayMax=30 # Timeout delay
Tolerance=2
# BEGIN ##############################
while true
do
StampNow=$(date +%s)/60 # stamp in minutes
StampFile=$(date -r "$File1" +%s)/60
let Delay=$StampNow-$StampFile
if [ $Delay -gt $DelayMax ]
then
echo "TIME STARTED = $(date +%Y-%m-%d_%H:%M:%S)" > $LogFile
echo "TIME ENDED = $(date +%Y-%m-%d_%H:%M:%S)" >> $LogFile
# etc.
exit 1
elif [ $StampFile -eq $StampOld ]
then
sleep $Tolerance minutes # Retry a bit later
else
StampOld=$StampFile
let NewDelay=$StampNow-$StampFile+15+$Tolerance # To synchronize with the updating
sleep $NewDelay minutes
fi
done
Below is the log
date: bad format character - s
date: illegal option -- r
Usage: date [-u] [+format]
date [-u] [mmddhhmm[[cc]yy]]
date [-a [-]sss.fff]
sam.ksh[11]: Delay=/60-/60: syntax error
sam.ksh[18]: /60: syntax error
sam.ksh[23]: NewDelay=/60-/60+15+2: syntax error
usage: sleep time
Please help i am a newbie in shell script