Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: right_column in ....includes/functions.php on line 4597

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in ....includes/class_bootstrap.php(1419) : eval()'d code on line 1

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in ....includes/class_bootstrap.php(1419) : eval()'d code on line 2

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in ....includes/class_bootstrap.php(1419) : eval()'d code on line 4

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in ....includes/class_bootstrap.php(1419) : eval()'d code on line 5
Tweeting through Terminal Linux article
Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications


This is a short tutorial explaining how to post to Twitter using command-line in Linux, without needing to even open up your web browser.

First, install the curl package:

sudo apt-get install curl

Next, create a script anywhere in your $PATH, for example twitter.sh inside ~/bin, where ~ is your home directory (make sure ~/bin is included in your $PATHvariable, in case echo $PATH doesn't return it, edit~/.bashrc and add a line like this: export PATH=/home/USER/bin/:$PATH).

The script twitter.sh should contain the following:

#!/bin/bash
curl -u USER:PASS -d status="$*" http://twitter.com/statuses/update.xml > /dev/null
echo "Message sent!"

Replace USER and PASS with your Twitter username and password, and then make the script executable:

chmod 755 ~/bin/twitter.sh

And now test it:

twitter.sh Hello, world! This is a test.

So just use it as:

twitter.sh YOUR MESSAGE




 
Rate This Article: poor excellent
 
Comments about this article
Good idea but too simple to be practical as is
writen by: iamSpOOk on 2010-03-23 18:36:00
Great idea.

A couple of points:

User name and password are now visible on your machine, and in any backups.
Maybe the -n option would help a bit.
! unexposed in a command line could be grabbed by the shell to substitute history.
Other special characters will muck up the input.
At least use single quotes for the message on the example:
twitter.sh 'Hello, world! This is a test.'

To fix this, the script could use raw mode and pull characters in one by one.

The attempt could fail and STDERR will go to the terminal, then it will say, "Message sent'
Checking return status would be a good idea.
RE: Good idea but too simple to be practical as is written by iamSpOOk:
Also, slight typing convenience...
writen by: Swillis on 2010-03-23 18:42:40
Just so the new guys/girls know, you don't need the ".sh" extension on the script. So, you could simply name it "twitter", for example, and then just type "twitter YOUR MESSAGE" in the terminal. It's really more of a keystroke saver/personal preference than anything.

Swill
RE: Also, slight typing convenience... written by Swillis:
RE: Also, slight typing convenience...
writen by: rockowtham on 2010-06-16 23:17:18
hi i tried this script..,

but its not working for me i m getting the error message as below please help me out

(gedit:12637): GnomeUI-WARNING **: While connecting to session manager:
Authentication Rejected, reason : MIT-MAGIC-COOKIE-1 authentication rejected.

thanx
Reply to rockowtham:

Comment title: * please do not put your response text here