]> www.fi.muni.cz Git - aoc.git/commitdiff
get.sh: better output, auto wait, input stats
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 8 Dec 2021 06:50:03 +0000 (07:50 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 8 Dec 2021 06:50:03 +0000 (07:50 +0100)
get.sh

diff --git a/get.sh b/get.sh
index a0d03f809344ade833b8c2ada9fb6018fc2fc42e..e5b394dffbc0269b96686ed1c5f045b420fb5ee3 100755 (executable)
--- a/get.sh
+++ b/get.sh
@@ -4,6 +4,23 @@ DAY=`date +%e|sed 's/ //g'`
 FILE="$((2*DAY - 1))in.txt"
 COOKIE=`cat cookie`
 
+START="6:00:02"
+MAXWAIT=300
+STARTSEC=`date -d "$START" "+%s"`
+NOW=`date "+%s"`
+WAITSEC=`expr $STARTSEC - $NOW`
+
+if [ $WAITSEC -gt 0 -a $WAITSEC -lt $MAXWAIT ]
+then
+       echo "Waiting for $WAITSEC seconds till $START ..."
+       sleep $WAITSEC
+fi
+
 URL="https://adventofcode.com/2021/day/$DAY/input"
-echo "Stahuji $URL do $FILE"
-curl -q -b "$COOKIE" "$URL" --output "$FILE"
+echo
+echo "Downloading $URL to $FILE"
+curl -s -b "$COOKIE" "$URL" --output "$FILE"
+echo
+echo "lines words chars"
+wc "$FILE"
+echo