File tree Expand file tree Collapse file tree 1 file changed +24
-10
lines changed
Expand file tree Collapse file tree 1 file changed +24
-10
lines changed Original file line number Diff line number Diff line change 88fi
99echo ${MONTH}
1010R_MONTH=${MONTH#* _} ; R_MONTH=${R_MONTH# 0}
11- BATCH=" cd fb-public-results\nls -1 cvid_responses_${MONTH} *.gz"
12- sftp -b <( echo -e " ${BATCH} " ) -P 2222 fb-automation@ftp.delphi.cmu.edu 2> /dev/null | \
13- grep " ^cvid" | \
14- awk -F_ ' BEGIN{print "cd fb-public-results"} {key=$3 $4 $5; if (key!=last && last!="") {print record} last=key; record=$0} END{print record}' | \
15- sed ' /^cvid/ s/^/get /' > fetch.sftp
16- sftp -b fetch.sftp -P 2222 fb-automation@ftp.delphi.cmu.edu
17- OUT=${MONTH/ _/ -}
18- Rscript ../monthly-files.R ${MONTH% _* } ${R_MONTH} . > ${OUT} .csv
19- gzip ${OUT} .csv
20- sftp -b <( echo -e " cd fb-public-results\nput ${OUT} .csv.gz" ) -P 2222 fb-automation@ftp.delphi.cmu.edu
11+
12+ # Save script's arguments to reference by name in perform_rollup_and_post() so the script's
13+ # positional arguments and perform_rollup_and_post's positional arguments don't get confusing.
14+ arg0=$0
15+ arg3=$3
16+ arg4=$4
17+ arg5=$5
18+
19+ perform_rollup_and_post ()
20+ {
21+ BATCH=" cd $1 \nls -1 cvid_responses_${MONTH} *.gz"
22+ sftp -b <( echo -e " ${BATCH} " ) -P 2222 fb-automation@ftp.delphi.cmu.edu 2> /dev/null | \
23+ grep " ^cvid" | \
24+ awk -F_ ' BEGIN{print "cd $1"} {key=$arg3 $arg4 $arg5; if (key!=last && last!="") {print record} last=key; record=$arg0} END{print record}' | \
25+ sed ' /^cvid/ s/^/get /' > fetch.sftp
26+ sftp -b fetch.sftp -P 2222 fb-automation@ftp.delphi.cmu.edu
27+ OUT=${MONTH/ _/ -}
28+ Rscript ../monthly-files.R ${MONTH% _* } ${R_MONTH} . > ${OUT} .csv
29+ gzip ${OUT} .csv
30+ sftp -b <( echo -e " cd $1 \nput ${OUT} .csv.gz" ) -P 2222 fb-automation@ftp.delphi.cmu.edu
31+ }
32+
33+ perform_rollup_and_post " fb-public-results"
34+ perform_rollup_and_post " protected-race-ethnicity-data"
You can’t perform that action at this time.
0 commit comments