mlblive-mastodon-scripts/plays/mlbplaypost.sh

36 lines
567 B
Bash
Raw Normal View History

2024-07-25 02:17:36 +00:00
#!/bin/bash
2024-07-26 03:34:35 +00:00
set -e
2024-07-31 01:05:02 +00:00
while getopts 'd:a:' opt
2024-07-27 00:14:39 +00:00
do
case $opt in
d)
db=$OPTARG
;;
2024-07-31 01:05:02 +00:00
a)
account=$OPTARG
;;
2024-07-27 00:14:39 +00:00
?)
exit 1
;;
esac
done
if [[ -z $db ]]
2024-07-26 03:48:57 +00:00
then
2024-07-27 00:14:39 +00:00
echo "$0:" '-d is required' >&2
2024-07-26 03:48:57 +00:00
exit 1
fi
2024-07-31 01:05:02 +00:00
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
2024-08-01 02:42:56 +00:00
# format each row of data retreived from the select statement and pipe to toot
2024-07-31 01:05:02 +00:00
fmt='printf "%s\n\n%s %s\n#%s %s\n#%s %s\n\n#baseball #live\n", $1, $2, $3, $4, $5, $6, $7'
2024-08-01 23:29:44 +00:00
post="\"toot post --using $account\""
sqlite3 $db < postplays.sql | awk -F  "{$fmt | $post; close($post)}"