Last active
November 17, 2018 01:44
-
-
Save ekeih/ada50e524dbcfffcd31ea383164603cb to your computer and use it in GitHub Desktop.
hetzner invoices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Put all your Hetzner invoices in a 'pdf' directory and keep the original name. | |
for filename in pdf/*.pdf; do | |
date="$(date -d "$(sed 's,.*_\(.*\)_.*,\1,' <<< "${filename})")" '+%s000000000')" | |
value="$(pdftotext "${filename}" - | grep -A 2 Brutto | tail -n 1 | sed "s;\([0-9]*\),\([0-9]*\).*€;\1.\2;")" | |
payload="invoice value=${value} ${date}" | |
curl -i -XPOST 'http://127.0.0.1:8086/write?db=hetzner' --data-binary "${payload}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment