Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- WGET=` which wget `
- SED=` which sed `
- RM=` which rm `
- CAT=` which cat `
- COPY=` which cp `
- GREP=` which grep `
- AWK=` which awk `
- UNZIP=` which unzip `
- ZIP=` which zip `
- MOVE=` which mv `
- download-data-zip()
- {
- echo "downloading data zip"
- ./auto_SCP.sh root@x.x.x.x:/home/name/data/data-3.0.zip ./
- echo "downloaded data zip."
- }
- create-new-data-zip()
- {
- echo "extracting data zip..."
- /usr/bin/unzip data-3.0.zip
- echo "extracted. removing old signatures file and xml files.."
- $RM ./data-3.0/abc/file1
- $RM ./data-3.0/xyz/*.xml
- echo "copying new file"
- $COPY ./file1 ./data-3.0/abc/
- echo "copied."
- curYr=$(date +%Y)
- echo "current year=$curYr"
- if [ ! -s yrFile ]
- then
- echo "yrFile is empty"
- for yr in $(seq 2002 $curYr)
- do
- echo $yr "going to " yrFile
- echo $yr >> yrFile
- done
- fi
- randNum=$(/usr/bin/shuf -n 1 yrFile)
- echo "random number=$randNum"
- echo "removing random year from yrFile and copying 2 xml files..."
- $SED "/$randNum/d" yrFile > yrFile1
- $MOVE yrFile1 yrFile
- $COPY ./cde/e-${randNum}.xml ./data-3.0/xyz/
- $COPY ./cde/e-${curYr}.xml ./data-3.0/xyz/
- /usr/bin/zip -Dr9 data-3.0.zip data-3.0
- echo "new data zip created."
- }
- main()
- {
- cd /root/Test/
- echo -n "" > /root/Test/cronOutput
- download-data-zip
- create-new-data-zip
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment