![](/img/trans.png)
[英]AWS data pipeline, run Unload of redshift from bash shell script and save to S3
[英]run cURL command and save output file to AWS S3 using shell script
我有一個名為getData.sh的 shell 腳本,用於執行 cURL POST 命令。
$1
$2
date=$(date '+%Y-%m-%d')
if [[ -n $1 ]] && [[ -n $2 ]] ; then
curl -4 -X POST \
-H "Content-Type:application/json" \
-H "Authorization:Basic xxxxxxxxxxx" \
-H "X-Async:false" \
-d \
'{
"variables": {
"start_ts" : "2020-11-03 '"${1}"'",
"end_ts" : "2020-11-03 '"${2}"'",
"select_columns" : "*",
"where": "content is NOT NULL"
}
}
' \
'http://xxxx:8080/app/v1/app/sQuery' > $date-$1-$2.gz
else
exit 1
菲
當我運行這個... ./getData.sh 13:00:00 14:00:00
這會輸出一個文件,如:
2020-12-01-13:00:00-14:00:00.gz
現在我想將此文件上傳到 S3。 我可以運行這樣的命令:
aws s3 cp /home/user/2020-12-01-13:00:00-14:00:00.gz s3://my-test-s3-bucket-2020-aws/
它可以工作,所以我想知道如何將它組合到一個腳本中,它會自動運行 aws s3 copy 命令並將其復制到 S3。 嘗試了一些東西,但它在文件 cURL 完成之前執行,所以上傳文件的一部分......
我嘗試了以下操作,但它無法讓我使用給定的文件名稱上傳它,因為它只是使用名稱“-”上傳它
curl xxx | aws s3 cp - s3://my-test-s3-bucket-2020-aws/
未經測試,但也許
'http://xxxx:8080/app/v1/app/sQuery' > $date-$1-$2.gz && aws s3 cp $date-$1-$2.gz s3://my-test-s3-bucket-2020-aws/
會有幫助的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.