shellスクリプトの実践を書く
1722 ワード
shellスクリプトの実践を書く
#!/bin/bash
array=`mysql -hxx.3.xx.66 -uprofile -p}vM0*4c2e#I7r#/S -N --execute="use profile;select u.id as id,u.name as name,u.email as email,n.number
as number from (select to_id,count(to_id) as number from reward_flower where perf_time_id=53 and status=3 group by to_id ) n ,user u,departme
nt d where n.to_id=u.id and u.department_id=d.id"`
echo "${array[*]}" > dataBase.log
files=dataBase.log
number=`cat dataBase.log|wc -l`
for i in `seq 1 $number`
do
a1=`sed -n "$i"p $files | awk '{print $1}'`
a2=`sed -n "$i"p $files | awk '{print $2}'`
a3=`sed -n "$i"p $files | awk '{print $3}'`
a4=`sed -n "$i"p $files | awk '{print $4}'`
#for j in `seq 1 $a4`
#do
#mysql -hxx.3.xx.66 -uprofile -p}vM0*4c2e#I7r#/S -N --execute="use profile;insert into score_info(user_id,from_id,from_info,score,status,dat
e_time) values('$a1',2,' ',30,2,'2012-09-15 18:55:45')"
echo "$a1, $a2, $a3 ,$a4"
#score_count=`mysql -hxx.3.xx.66 -uprofile -p}vM0*4c2e#I7r#/S -N --execute="use profile;select * from score_count where user_id='$a1'"`
# if [ "$score_count" ]
# then
total=$[30*$a4]
echo $a1,$a2
mysql -hxx.3.xx.66 -uprofile -p}vM0*4c2e#I7r#/S -N --execute="use profile;insert into score_count(user_id,surplus_score,total_score)
values('$a1',0,'$total')"
# fi
#done
done