shell语句出现syntax error near unexpected token `;;'错误
代码如下#!/bin/bashecho"1:上班签到"echo"2:下班签出"echo"3:缺勤信息查询"echo"请输入命令编号:(1,2,3)"readanswere...
代码如下
#! /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格式了,还是不行.... 展开
#! /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格式了,还是不行.... 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询