test.sh脚本内容:
#!/bin/sh
# mysql_conf
mysql_host=hadoop102
mysql_database=gmall_report
mysql_user=root
mysql_password=000000
mysql_port=3306
# file_dir
text_path=/opt/test/test.txt
e=0
cat $text_path | while read line
do
if [ "${e}" -eq "0" ]
then
echo "successful execution"
echo $line
mysql -h$mysql_host -u$mysql_user -p$mysql_password -P$mysql_port -D $mysql_database -e "$line"
e=$?
else
echo $e
echo "execution error"
exit 1
fi
done
---------------------------------------------------------------------------------------------------------------------------------
test.txt文件内容:
cat test.txt
call test_add;