代码如下
#! /bin/bash
echo "1:上班签到"
echo "2:下班签出"
echo "3:缺勤信息查询"
echo "请输入命令编号:(1,2,3)"
read answer
echo "请输入您的用户名"
read name
echo "请输入您的密码"
read password
if [ ! -f "/userinfo.dat" ]; then
touch userinfo.dat
fi
if [ ! -f "/check.dat" ]; then
touch check.dat
fi
d=$(date +%H%M)
cat > tmp.dat << EOF
$name"-" $password "登录系统" $d
EOF
cat -n tmp.dat >> userinfo.dat
rm tmp.dat
case “$answer” in
1)if( $d –gt 0800 )
echo "您已迟到"
da=$(date +%Y%H%M)
cat > tmp.dat << EOF
$name"于" $ da"迟到"
EOF
cat -n tmp.dat >> check.dat
rm tmp.dat
;;
2)if( $d –lt 1800 )
echo "您已选择早退"
da=$(date +%Y%H%M)
cat > tmp.dat << EOF
$name"于" $ da"早退"
EOF
cat -n tmp.dat >> check.dat
rm tmp.dat
;;
3)cat check.dat
;;
esac
PS:代码已经用notepad++转为unix格式了,还是不行....
1,cat > tmp.dat << EOF
$name"äº" $ da"è¿å°"
EOF
è¿é$ daæ¯ä¸æ¯å¤äºä¸ªç©ºæ ¼
2,ifè¯å¥æ£ç¡®çåæ³æ¯
if æ¡ä»¶
then
æ§è¡
done
3,if( $d âlt 1800 )
åºè¯¥åæ if [ "$d" -lt "1800" ]ï¼æ³¨æé½æç©ºæ ¼è¿½ç
if
then
fi
è¿æ ·æ对ï¼2æ¯äºã