Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- files=/home/*****/ringup_good/*
- newfile=/home/*****/ringup_good.csv
- logfile=/home/******/log/pragent_first_ringup_good.log
- cat $files | iconv -f CP1251 -t UTF-8 > $newfile;
- cat $newfile >> $logfile;
- rm $files;
- mysql -u user -ppwd --local-infile DB -e "source /home/*****/pragent_first_ringup_good.sql;";
- rm $newfile;
- ///////////////////////////////////////
- ////////////////SQL FILE pragent_first_ringup_good.sql
- SET @project='pragent', @ringup='noans', @type=1;
- CREATE TEMPORARY TABLE autoringup_hist_tmp
- SELECT DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,pc_id
- from general.autoringup_hist
- where 1=2
- ;
- commit;
- LOAD DATA LOCAL INFILE '/home/*****/ringup_noans.csv'
- INTO TABLE autoringup_hist_tmp
- CHARACTER SET UTF8
- FIELDS TERMINATED BY ';'
- OPTIONALLY ENCLOSED BY '\"'
- LINES TERMINATED BY '\n'
- (@dttm,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,pc_id)
- SET DateTime = STR_TO_DATE(@dttm,'%d.%m.%Y %H:%i:%s')
- ;
- commit;
- insert into general.autoringup_hist
- (DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,ringup,pc_id,project,type)
- select
- DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,@ringup,pc_id,@project,@type
- from autoringup_hist_tmp
- ;
- commit;
- update privat.pragent_main_data t1, autoringup_hist_tmp t2
- set t1.date_noans = t2.DateTime,
- t1.cnt_noans = t1.cnt_noans+1,
- t1.inwork = 0,
- t1.date_o = now()
- where t1.phone = t2.Abon
- ;
- commit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement