From addf696db8dedb7b8df4a496d3eb1a021f9bcc51 Mon Sep 17 00:00:00 2001 From: ken restivo Date: Tue, 12 Jan 2016 13:19:21 -0800 Subject: Add very simple, minimalist posting shell script. --- util/hz | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 util/hz (limited to 'util/hz') diff --git a/util/hz b/util/hz new file mode 100755 index 000000000..3be684a64 --- /dev/null +++ b/util/hz @@ -0,0 +1,33 @@ +#!/bin/bash + +# Simple, minimalist command line tool to post status to hubzilla via the API. Requires curl. +# Put it in your path, and sneeze your statuses to the zot network from your shell. + +CONF=${HOME}/.hubzilla + +usage () { +echo "usage: hz [conffile]" +echo "Create a conf file, either in .hubzilla in your home directory, or supplied as an arg" +echo " USER=youruserame " +echo " PASS=yourpass" +echo " HUB=your.hub.domain.org" +echo +echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit control-d when done." + +} + +CUR=`which curl` + +[ "$CUR" ] || { echo "curl is not installed or on your path"; usage; exit 1; } + +[ "$1" ] && CONF="$1" + +[ "$USER" ] || { echo "no USER"; usage; exit 1; } +[ "$PASS" ] || { echo "no PASS"; usage; exit 1; } +[ "$HUB" ] || { echo "no HUB"; usage; exit 1; } + +echo "enter your message to be posted as $USER @ $HUB, then hit control-d:" + +(read MSG; curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update ) + + -- cgit v1.2.3 From bbc1a1f1fb925fc804585118364297acb5c8fa1f Mon Sep 17 00:00:00 2001 From: ken restivo Date: Tue, 12 Jan 2016 13:20:37 -0800 Subject: Source the conf. --- util/hz | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/hz') diff --git a/util/hz b/util/hz index 3be684a64..74d948bdd 100755 --- a/util/hz +++ b/util/hz @@ -22,6 +22,9 @@ CUR=`which curl` [ "$1" ] && CONF="$1" + +. ${CONF} + [ "$USER" ] || { echo "no USER"; usage; exit 1; } [ "$PASS" ] || { echo "no PASS"; usage; exit 1; } [ "$HUB" ] || { echo "no HUB"; usage; exit 1; } -- cgit v1.2.3 From 93096a9db896fb0a7489b661ca744ea75a071198 Mon Sep 17 00:00:00 2001 From: ken restivo Date: Tue, 12 Jan 2016 18:51:57 -0800 Subject: Correct docs. --- util/hz | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util/hz') diff --git a/util/hz b/util/hz index 74d948bdd..baa5bfb55 100755 --- a/util/hz +++ b/util/hz @@ -12,7 +12,7 @@ echo " USER=youruserame " echo " PASS=yourpass" echo " HUB=your.hub.domain.org" echo -echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit control-d when done." +echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit ENTER to send." } @@ -29,7 +29,7 @@ CUR=`which curl` [ "$PASS" ] || { echo "no PASS"; usage; exit 1; } [ "$HUB" ] || { echo "no HUB"; usage; exit 1; } -echo "enter your message to be posted as $USER @ $HUB, then hit control-d:" +echo "enter your message to be posted as $USER @ $HUB, then hit ENTER to send:" (read MSG; curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update ) -- cgit v1.2.3 From b58177e3c60fd6dfbe01549bb7894d9c84d40710 Mon Sep 17 00:00:00 2001 From: ken restivo Date: Thu, 14 Jan 2016 21:05:36 -0800 Subject: Use ctrl-d for multi-line messages. --- util/hz | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'util/hz') diff --git a/util/hz b/util/hz index baa5bfb55..cb6ccf419 100755 --- a/util/hz +++ b/util/hz @@ -12,7 +12,7 @@ echo " USER=youruserame " echo " PASS=yourpass" echo " HUB=your.hub.domain.org" echo -echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit ENTER to send." +echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Use ctrl-D to send.." } @@ -29,8 +29,10 @@ CUR=`which curl` [ "$PASS" ] || { echo "no PASS"; usage; exit 1; } [ "$HUB" ] || { echo "no HUB"; usage; exit 1; } -echo "enter your message to be posted as $USER @ $HUB, then hit ENTER to send:" +echo "enter your message to be posted as $USER @ $HUB, then hit Ctrl-D to send." -(read MSG; curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update ) +MSG=$(cat) + +curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update -- cgit v1.2.3