Sep 16, 2008

Update Facebook status through Bash, using cURL

anger management part 2 peeps!

A nice simple bash script to update the status on facebook from the command line. Pretty straight forward, using cURL here again. As usual, edit the email and passord. Script takes one argument, the status. There's no error-checking so there really isn't a way to know if it was successful or not. I'll add that in sometime later.

I love cURL!

edit: some installation instructions for the younger peeps
1) copy past it into a new file on the desktop say fbupdater
2) open terminal, type "sudo cp /Desktop/fbupdater /usr/local/bin/fbupdater"
3) type "chmod a+x /usr/local/bin/fbupdater"



and that should do it.


#!/bin/bash


email=YOUR-EMAIL
pass=YOUR-PASSWORD

stat=$1

cd $HOME

echo "logging in"

pfID=`curl -L --silent -A "MOZILLA/5.0" -b cookie -c cookie -d "email=${email}" \
-d "pass=${pass}" -d "login=Log+In" http://m.facebook.com/login.php | \
sed -nr 's/.*post_form_id" value="(\w+)".*/\1/p'`

echo "updating"
curl --silent -L -A "MOZILLA/5.0" -b cookie -c cookie -d "post_form_id=${pfID}" \
-d "status=${stat}" -d "update=Update" http://m.facebook.com/home.php > /dev/null

if [ -e cookie ]
then
rm cookie
else
echo "no cookie file? something went wrong?"
fi

9 Comments:

Anonymous said...

Doesn't work with the new Facebook.

Vivek said...

Dosent work.
Can you post an update.

SoE said...

I would recommend using FBCMD for all command line interaction with facebook.

bozie said...

:bump: how can haz updates with teh command lines?

SoE said...

has http://fbcmd.dtompkins.com/

Anonymous said...

There is a new script for that:

http://360percents.com/posts/bash-script-to-update-facebook-status-linux-mac-os-x/

suman said...

doesnt work mate

SoE said...

This was posted ages ago. Facebook has undergone some significant changes since then.

Anonymous said...

http://www.systmbx.com/scripts/bash-script-to-update-facebook-status-from-command-line

Post a Comment