Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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.

share|improve this question
    
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
    
@DennisWilliamson I'll try that, thank you! –  Hugo Oct 27 '12 at 11:52
2  
@Hugo Can you post the solution for future reference? –  Alex Chamberlain Oct 27 '12 at 14:24
show 5 more comments

1 Answer

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

share|improve this answer
    
The space is optional and accepted. –  Dennis Williamson Oct 28 '12 at 10:45
    
oh is it? never saw it with a space. –  Mose Oct 28 '12 at 11:37
1  
The first two bullet points under Selected issues. –  Dennis Williamson Oct 28 '12 at 17:25
    
thank you very much :-) –  Mose Oct 28 '12 at 19:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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