有人可以幫我理解下面這段代碼,它決定了從數據庫中選出數據的開始和結束日期。瞭解一個ksh腳本部分
# Get the current time as the stop time.
#
stoptime=`date +"%Y-%m-%d %H:00"`
if test $? -ne 0
then
echo "Failed to get the date"
rm -f $1/.optpamo.pid
exit 4
fi
#
# Read the lasttime file to get the start time
#
if test -f $1/optlasttime
then
starttime=`cat $1/optlasttime`
# if the length of the chain is zero
# (lasttime is empty) It is updated properly
# (and I wait for the following hour)
if test -z "$starttime"
then
echo "Empty file lasttime"
echo $stoptime > $1/optlasttime
rm -f $1/.optpamo.pid
exit 5
fi
else
# If lasttime does not exist I create, it with the present date
# and I wait for the following hour
echo "File lasttime does not exist"
echo $stoptime > $1/optlasttime
rm -f $1/.optpamo.pid
exit 6
fi
感謝
哪些部分你不清楚? – 2010-01-07 19:27:33
看起來您對腳本片段的格式有問題。如果您突出顯示它們並按下編輯器上方的按鈕'0101'圖標,它應該將它們格式化爲代碼。 – 2010-01-08 06:36:07
該劇本足夠好評,所以你不明白什麼? – ghostdog74 2010-01-08 06:41:37