mlblive-mastodon-scripts/games/mlbfinalpost.sh

36 lines
550 B
Bash
Raw Normal View History

2024-08-04 20:31:07 +00:00
#!/bin/bash
set -e
while getopts 'd:a:' opt
do
case $opt in
d)
db=$OPTARG
;;
a)
account=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
# format each row of data retreived from the select statement and pipe to toot
fmt='printf "Final:\n\n%s %s\n%s %s\n\n#baseball #live\n", $1, $2, $3, $4'
post="\"toot post --using $account\""
2024-08-04 20:56:07 +00:00
sqlite3 $db < postfinal.sql | awk -F  "{$fmt | $post; close($post)}"