tonybaldwin | blog

non compos mentis

Post to Posterous with bash, curl and vim

leave a comment »

Here we have a nifty little script to post to from the bash terminal with vim and curl.

# post to posterous from bash cli with curl
# I could do this with read -p "Enter ur username d0od: " username
# kind of thing, but I just hardwired my info in.
# edit accordingly for your info.

# creates a date stamp for naming the post file
filedate=$(date %m%d%y%H%M%S)

# set post title
read -p "Enter a post title: " ptitle

# write post in vim
vim $filedate.ppost pbody="$(cat $filedate.ppost)"

# send post to posterous with curl
if [[ $(curl -X POST -u $username:$password -d "api_token=$apitok" -d "post[title]=$ptitle" -d "post[body]=$pbody" | grep error) ]]; then
echo "Too bad, do0d...FAIL!"
echo "Success! Posted to Posterous!"

# moved post to dir for safekeeping.
# you can use different dir, d00d
mv $(pwd)/$filedate.ppost ~/Documents/fposts/

# open a browser for a look-see?
read -p "Shall we have a look in your browser now? (y/n): " browse

if [ $browse = "y" ]; then
	xdg-open http://$


Here is first post made with this script to my posterious. In truth, however, I do not use posterous, really. I will be using this information to add posterous support to Xpostulate before the week is out, however, per a user request. The experimentation with curl was to get my head around their API and posting procedure.

Here is the relevant wiki page for this script.



posted with Xpostulate.


Written by tonybaldwin

September 19, 2011 at 9:46 pm

Posted in baldwinsoftware

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: