20 October 2013

mail bash script for SSMTP

Save this in your path and chmod +x for a nice tiny  "mail" command.

#!/bin/bash

SENDER=`whoami`
RECIPIENT=$1
shift 1
SUBJECT=$*

if test -z "$RECIPIENT"
then 
echo "Missing parameters.

Usage: mail RECIPIENT SUBJECT

  RECIPIENT: Target email address
  SUBJECT: Mail subject


Pascal Brax - http://pascalbrax.blogspot.com
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND"
exit
fi

if test -z "$SUBJECT"
then SUBJECT="Small mail"
fi

echo To: $RECIPIENT
echo Subject: $SUBJECT
echo -n "Short message: "
read MESSAGE
BODY="To: $RECIPIENT
Subject: $SUBJECT

$MESSAGE"
echo "
Sending..."
echo "$BODY" | ssmtp $RECIPIENT 
echo "Mail sent."

16 June 2013

PHP check for the latest Sony Xperia Z firmware

So, I was inspired by this post on XDA, I just wanted put some lines together and created this page:

http://scavenger.ch/sonyupdate

What it does is simply check against http://fuas.sonymobile.com and retrieve the XML with the latest firmware version for the Xperia Z mobile phone (both C6602 and C6603 models). This page can be bookmarked with own model and custom number.

This little stuff has been made with parts of crXml parser from freshmeat.

1 February 2013

Maildir bash script check for new mail

I've set up that tiny script and saved it as "newmail" in /usr/local/bin and added a line at the end of /etc/bash/bashrc

And here it is:

#!/bin/bash

if [ -d ~/.maildir ]
then
  newmail=`find ~/.maildir/new -type f | wc -l`
  if [ $newmail -gt 0 ]
  then
    echo "You have $newmail new mails."
  else
    echo "No new mail for you."
  fi
fi


This script works out-of-the-box for the Gentoo and Funtoo distro, YMMV.