How to tweet from shell

How to tweet from a shell script, since twitter started using the OAuth authentication scheme and writing scripts/apps for twitter became more challenging to integrate with, this entry is about how to integrate shell scripts into twitter, the application for that can be limitless and may include :

  1. using twitter as monitoring platform.
  2. using twitter to notify you of certain events.
  3. using twitter as an interfacing channel with your machine.
  4. schedule tweets.

This entry is based on ( however I tried to simplify and compress the instructions as much as I could:

  1. verify you have curl installed on your machine (#which curl), if not you have to install it.
  2. download the three attached scripts and place them into one directory (,,
  3. have at least one valid twitter account (to register the script).

Start by registering the Twitter script on twitter, simply go to and click on “register a new app” fill the fields, and then click “Register Application”, copy “Consumer Key” and “Consumer Secret” from the application details page.

Create a new file and name it .tcli.rc (any other name would do as well), place the following two lines in it, using the data you acquired from the application details page, place the file in your home (~).


Modify the two files (, as a work around to avoid placing them in the path:

in replace

in replace 
(( $? != 0 )) && echo 'Unable to locate! Make sure it is in searching PATH.' && exit 1
source "$OAuth_sh"



and in


(( $? != 0 )) && echo 'Unable to locate! Make sure it is in searching PATH.' && exit 1
source "$OAuth_sh"




Now your work as a developer is done, all you need to do is to assume the users role and enable the script to tweet using your account, please login to twitter as the user you want your script to use.


./ -c statuses_update -s "hello world"

You’ll be provided with a link and a prompt requesting a pin, click on the link, acquire the pin, paste it and click enter, now your script is ready to tweet.


You can now integrate it into any other script you’ve got :).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s