2

I'm trying to get my Pi to post the amount of used RAM to Twitter.

I'm using a script I modified myself from here, although I'm not very proficient in bash..

This is the file, it is located in /home/pi/bin/memtweet;

#! /bin/bash

# Configuration variables
TWIT_USER="USERNAME"
TWIT_SECRET="SUPERTWEET_PASS"

# Other variables
TWIT_URL="http://api.supertweet.net/1/statuses/update.xml"
TWEET=$(free -m | awk '/^Mem:/  { printf( "%s\n", $3 ); }')
curl -u $TWIT_USER:$TWIT_SECRET -d "status=RAM USAGE: $TWEET MB" $TWIT_URL -s > /dev/null

I'm using SuperTweet (as you can see) and echoing the amount of RAM, actually works.

I've use crontab -e to try and run it every 5 minutes (although I'll change it to hourly, I just wanted to see if it could work).

5 * * * * /home/pi/bin/memtweet

I've tried setting the cron for both root and the user, pi, but neither of them work.

Here's the last cron error I received when I was attempting to run the script through the pi user;

/bin/sh: 1: pi: not found

If anyone has an ideas as to how I could make this work, I would be very grateful!

EDIT: It looks like it could be the bash script, I've tried running it a few times and it doesn't seem to be posting to Twitter.

  • Build it up slowly. Does the curl command work on the command line? – Alex Chamberlain Oct 27 '12 at 11:35
  • Yes, it does. I've isolated the problem, I'm now using a different piece of code, still bash, and the cronjob still doesn't seem to work.. – Hugo Oct 27 '12 at 11:40
  • Your crontab entry says to run the job on the fifth minute of every hour. To run it every five minutes: */5 * * * * /home/pi/bin/memtweet – Dennis Williamson Oct 27 '12 at 11:46
  • It still doesn't seem to be working.. – Hugo Oct 27 '12 at 12:06
  • 2
    @Hugo Can you post the solution for future reference? – Alex Chamberlain Oct 27 '12 at 14:24
3

Maybe a bit farcical, but use #!/bin/bash and not #! /bin/bash. I think it doesn't recognize the correct shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.