1.Шелл и пр. (bc,ls,egrep,wc,rm,mv,cp)
2.7-zip
3.Верба-OW
4.iconv
5.blat
#!/c:/usr/bin/sh #Const MailToList="p365@vsk.bank.ru" MailFrom="p365@vsk.bank.ru" MailSubj="365-P RPO/ROO" SMTPServer="10.10.240.10" Convertor="C:/365P/nal2dia.exe" Verba="FColseOW.exe" UnCab=c:/progra~1/7-zip/7z.exe UnArj=c:/progra~1/7-zip/7z.exe Log="C:/365P/take365.log" PtkInPath="P:/ARH" ProcdPath="C:/365P/PROCESSED" PrgDir="C:/365P/PROCESSING" UnpktDir="C:/365P/UNPACKED" DiasoftIn="C:/365P/4X4/IN" DiasoftArc="C:/365P/4X4/ARC" DiasoftTmp="C:/365P/4X4/TMP" DiasoftOut="O:/DIASOFT/LOAD/365P" VerbaDir="C:\\PROGRA~1\\MDPREI\\-OW~1" ByDatePath=`date +%Y`/`date +%m`/`date +%d` PtkInFiles=$PtkInPath/$ByDatePath ProcdFiles=$ProcdPath/$ByDatePath PTKFMask="^[mM][zZ]*" NalFMask="^[Rr][OoPp]*" if ! test -d $ProcdFiles ; then ; mkdir -p $ProcdFiles ; fi InFilesList=`ls -1 --sort=t $PtkInFiles| egrep $PTKFMask` PrdFilesList=`ls -1 --sort=t $ProcdFiles` NumInFiles=`ls -1 $PtkInFiles | egrep $PTKFMask | wc -l` NumPrdFiles=`ls -1 $ProcdFiles | egrep $PTKFMask | wc -l` echo `date +%c` Input files total: $NumInFiles >>$Log echo `date +%c` Already processed files: $NumPrdFiles >>$Log # FilesToProc=`echo $NumInFiles - $NumPrdFiles | c:/usr/bin/bc` ((FilesToProc=$NumInFiles - $NumPrdFiles)) echo `date +%c` Files to processing: $FilesToProc >>$Log if [ FilesToProc -lt "1" ] then echo `date +%c` Nothing to do, honey, exiting... >>$Log exit else #if found smth new! # copy it to processed out path to remember what already processed echo $InFilesList | head -n $FilesToProc | xargs --replace='{}' cp $PtkInPath/`date +%Y`/`date +%m`/`date +%d`/'{}' $PrgDir/'{}' echo `date +%c` `echo $InFilesList | head -n $FilesToProc` >>$Log # unpack all CAB (!) files to UNPACKED directory echo $InFilesList | head -n $FilesToProc | xargs --replace='{}' $UnCab e $PrgDir/'{}' -o$UnpktDir # unpack all AFN*.arj files to UNPACKED directory ls -1 $UnpktDir | egrep "^[Aa][Ff][Nn]*" |xargs --replace='{}' $UnArj e $UnpktDir/'{}' -o$UnpktDir # move all RP* files to 4x4 directory echo `ls -1 $UnpktDir | egrep $NalFMask |xargs --replace='{}' mv -f $UnpktDir/'{}' $DiasoftIn/'{}'` # clear all other shit rm $UnpktDir/* # move all processed mz* files from PROCESSING to PROCESSED echo $InFilesList | head -n $FilesToProc | xargs --replace='{}' mv -f $PrgDir/'{}' $ProcdFiles/'{}' #decode here if [ `ls -1 $DiasoftIn | egrep $NalFMask | wc -l` -gt 0 ] then ScriptName=./`date +%s`.scr echo $ScriptName echo "Uncrypt $DiasoftIn\\\r*.*" > $ScriptName echo Start >> $ScriptName echo Exit >> $ScriptName `$VerbaDir/$Verba /@$ScriptName` echo `date +%c` Found new RPO/ROO files:`ls -1 $DiasoftIn | egrep $NalFMask | wc -l` >>$Log echo `date +%c` `ls -1 $DiasoftIn | egrep $NalFMask` >>$Log LogFile=./`date +%s`.log for f in $DiasoftIn/[Rr][OoPp]* do echo $f >>$LogFile echo \\r >>$LogFile cat $f | iconv.exe -s -f 866 -t cp1251 >>$LogFile echo \\f\\r >>$LogFile done if ! test -d $DiasoftArc/$ByDatePath ;then; mkdir -p $DiasoftArc/$ByDatePath; fi ls -1 $DiasoftIn | egrep $NalFMask | xargs --replace='{}' cp -i $DiasoftIn/'{}' $DiasoftArc/$ByDatePath/'{}' # convert format to diasoft 4x4 compartible files ls -1 $DiasoftIn | egrep $NalFMask | xargs --replace='{}' $Convertor $DiasoftIn/'{}' $DiasoftTmp/'{}' echo `date +%c` Sucsessfully converted files:`ls -1 $DiasoftTmp | egrep $NalFMask | wc -l` >>$Log echo `date +%c` `ls -1 $DiasoftTmp | egrep $NalFMask` >>$Log ls -1 $DiasoftTmp | egrep $NalFMask | xargs --replace='{}' mv $DiasoftTmp/'{}' $DiasoftOut/'{}' MailBody="365-P RPO/ROO received at "`date +%c` blat.exe -t $MailFrom -f $MailToList -s $MailSubj -i $MailFrom -q -server $SMTPServer -body "$MailBody" -attach $LogFile rm $LogFile rm $DiasoftIn/* rm $ScriptName fi fi
2 комментария:
есть пару вопросов по работе с 365
куда тебе написать ?
d.zelenov at гмайл ком
Отправить комментарий