if else 语句无法执行,即无法执行then里面的数据库插入 也无法执行else 里面的数据库插入 ,求大神指导

sh/bash/dash/ksh/zsh等Shell脚本
回复
gxwu
帖子: 3
注册时间: 2014-11-09 9:44
系统: ubuntu14.04

if else 语句无法执行,即无法执行then里面的数据库插入 也无法执行else 里面的数据库插入 ,求大神指导

#1

帖子 gxwu » 2015-04-07 15:10

#! /bin/bash

time=`mysql -u root apk -se "select times from Times where package='com.zhejiangdaily'"` ; //结果为time=7;


if [ ! $time ]
then
echo "hello";
mysql -u root apk <<EOF 2>/dev/null
insert into Cap values("$pkg","$starttime","$endtime",$mytimes,"??");
insert into Times values("$pkg",$mytimes);
else
echo "hellolll";
mysql -u root apk <<EOF 2>/dev/null
insert into Cap values("$pkg","$starttime","$endtime",$mytimes,"??");
update Times set times=times+1 where package="$pkg";
EOF
fi
回复