我需要在mariadb数据库中插入行后运行一个bash脚本。
这是我的剧本:
mysql {database} -u{user} -p{passwd} < req_mp3.sql #Create csv of my table
liste_requete=$(ls /tmp | grep csv)
for i in ${liste_requete[@]}; do
line=$(cat /tmp/${i})
for b in ${line[@]}; do
mp3=$(echo ${b}| awk -F"|" '{print $1}')
id=$(echo ${b} | awk -F"|" '{print $3}')
time=$(ffmpeg -i /tracks/${mp3} 2>&1 | grep Duration | awk '{print $2}' | tr -d ,i | awk -F"00:" '{print $2}'| awk -F"." '{print $1}')
printf " UPDATE tbl_mp3 SET mp3_url = '${mp3}', mp3_duration = '${time}', cat_id = '${tag}' , status= '1' WHERE id='${id}'; \n" >> update.sql
done
done
mysql {database} -u{user} -p{passwd} < update.sql
我厌倦了这个:
DELIMITER ;;
CREATE TRIGGER `tbl_mp3_ai` AFTER INSERT ON `tbl_mp3` FOR EACH ROW
BEGIN
system /imports/fnish.sh
END;;
DELIMITER ;
但不工作
你能帮助我吗?
thx:)