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
|
|
|
# send data to the the table in the MYSQL database
|
|
|
|
|
|
|
|
MYSQL=`which mysql`
|
|
|
|
|
|
|
|
if [ $# -ne 2 ]
|
|
|
|
then
|
2019-10-10 08:56:31 +08:00
|
|
|
echo "Usage:mtest2 emplid lastname firstname salary"
|
2019-05-10 11:17:57 +08:00
|
|
|
else
|
2019-10-10 08:56:31 +08:00
|
|
|
#脚本变量一定要用双引号,字符串变量使用单引号
|
|
|
|
statement=" insert into em_admin values(NULL, '$1', $2)"
|
|
|
|
$MYSQL emwjs -u test << EOF
|
|
|
|
$statement
|
2019-05-10 11:17:57 +08:00
|
|
|
EOF
|
2019-10-10 08:56:31 +08:00
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo Data successfully added
|
|
|
|
else
|
|
|
|
echo Problem adding data
|
|
|
|
fi
|
2019-05-10 11:17:57 +08:00
|
|
|
fi
|