From 6f92bf82e50fd608f4ec0eaa95f9936b9b202412 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 2 Sep 2017 22:22:17 +0530 Subject: Silence curl. * apod-bot.sh: Add -s and -S flags to curl to suppress output unless there is an error. --- apod-bot.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apod-bot.sh b/apod-bot.sh index b79f261..4e7085a 100755 --- a/apod-bot.sh +++ b/apod-bot.sh @@ -20,7 +20,7 @@ BOT_PASSWORD=secret-password-here APOD_BASE_URL=https://apod.nasa.gov/apod # Download HTML page, and scrape required information -APOD_HTML=$(curl $APOD_BASE_URL/astropix.html) +APOD_HTML=$(curl -sS $APOD_BASE_URL/astropix.html) TITLE=$(echo "$APOD_HTML" | pup 'center:nth-child(2) > b:nth-child(1) text{}' \ | sed -e 's/^ *//' -e 's/ *$//') @@ -40,8 +40,8 @@ PAGE_LINK=$APOD_BASE_URL/ap$DATE.html NOTICE="$TITLE $PAGE_LINK $MEDIA_LINK" # Ensure we are not publishing a duplicate notice -PREVIOUS_NOTICE=$(curl -u "$BOT_USERNAME:$BOT_PASSWORD" $SOCIAL_API_URL/statuses/home_timeline.json \ - | jq -r '.[0] | .text') +PREVIOUS_NOTICE=$(curl -sSu "$BOT_USERNAME:$BOT_PASSWORD" $SOCIAL_API_URL/statuses/home_timeline.json \ + | jq -r '.[0] | .text') if [[ "$NOTICE" = "$PREVIOUS_NOTICE" ]] then echo "Notice \"$NOTICE\" already published. Aborting..." >&2 @@ -53,6 +53,6 @@ wget --spider $MEDIA_LINK wget --spider $PAGE_LINK # Publish notice -curl -u "$BOT_USERNAME:$BOT_PASSWORD" --data-urlencode "status=$NOTICE" \ +curl -sSu "$BOT_USERNAME:$BOT_PASSWORD" --data-urlencode "status=$NOTICE" \ $SOCIAL_API_URL/statuses/update.json \ | jq -r '"Published notice \"\(.text)\" on \(.created_at)"' -- cgit v1.2.3