linux-tutorial/codes/shell/示例脚本/进阶脚本/问题跟踪数据库/记录问题.sh

67 lines
1.5 KiB
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#
# Record_Problem - records system problems in database
#
###########################################################
#
# Determine mysql location & put into variable
#
MYSQL=`which mysql`" Problem_Trek -u root"
#
###########################################################
#
# Create Record Id & Report_Date
#
#ID_NUMBER=`date +%y%m%d%H%M`
#
REPORT_DATE=`date +%y%m%d`
#
############################################################
#
# Acquire information to put into table
#
echo
echo -e "Birefly describe the problem & its symptoms: \c"
#
read ANSWER
PROB_SYMPTOMS=$ANSWER
#
# Set Fixed Date & Problem Solution to null for now
#
FIXED_DATE=0
PROB_SOLUTIONS=""
#
#############################################################
#
# Insert acquired information into table
#
2019-10-10 08:56:31 +08:00
echo
2019-05-10 11:17:57 +08:00
echo "Problem recorded as follows:"
echo
id=$($MYSQL -e "INSERT INTO problem_logger VALUES (null,$REPORT_DATE,$FIXED_DATE,'$PROB_SYMPTOMS','$PROB_SOLUTIONS');SELECT LAST_INSERT_ID() id")
id=`echo $id | gawk '{print $2}'`
2019-10-10 08:56:31 +08:00
$MYSQL << EOF
2019-05-10 11:17:57 +08:00
SELECT * FROM problem_logger where id_number=$id\G
EOF
#
#############################################################
#
# Check if want to enter a solution now
#
2019-10-10 08:56:31 +08:00
echo
2019-05-10 11:17:57 +08:00
echo -e "Do you have a solution yet?(y/n) \c"
read ANSWER
#
case $ANSWER in
2019-10-10 08:56:31 +08:00
y | Y | YES | yes | Yes | yEs | yeS | YEs | yES)
./Update_Problem.sh $id
#
;;
*)
# if answer is anything but yes, just exit script
;;
2019-05-10 11:17:57 +08:00
esac
#
############################################################