Things I tend to forget


CLI Blogging code

Bookmark this category
How it’s done. I started out with a bash function as described earlier. The function code is below:
function blog() { echo "$2" | mail -s "$1" address@example.com; }

Then I noticed I would need more freedom to write longer text, without leaving the shell. So here goes the “blog” bash script. I’m using the postie wordpress plugin on the server side, so things are a bit more manageable. I may add more to this later if I get time.

#!/bin/bash
if [ -n "$2" ]; then
BODY=$2
else
vi tmpfile; BODY=`cat tmpfile`; rm tmpfile
fi
if [ -n "$1" ]; then
SUBJECT=$1
else
echo -n "Subject:"; read SUBJECT
fi
echo "$BODY" | mail -s "$SUBJECT" address@example.com

Similar Posts:




Another CLI post (via postie)

Bookmark this category
Testing CLI blogging with temp files and VI integration. weeee!

Similar Posts:

    None Found




Live From The Field (via postie)

Bookmark this category
Another CLI post

Similar Posts:

    None Found




CLI blogging with Postie (via postie)

Bookmark this category
Another blogging test using the postie plugin

Similar Posts:




Quick Note

Testing the previous entry, and quick-blogging from the shell

Similar Posts:

    None Found




Dave’s Notepad

We were chatting in the morning and my colleague Dave said:

echo “blog post about distro choice” | mail -s “blog post” david@mydomain.org
that’s my ‘notepad’. 🙂

I thought that was pretty useful, but tried to make it easier by creating a bash alias. Turns out it’s better to use a bash function instead. (see this note). So my ‘jot’ function is:
function jot() { echo "$1" | mail -s "$2" abdallah@mydomain.com; }

I also noticed, that emails sent from my laptop were not reaching. It seems Ubuntu comes with Exim4 as a default MTA. I’m not too familiar with Exim, so I used the occasion to learn a new trick.

I might use this for micro-blogging next… let me go set it up 🙂

Similar Posts: