01 Jun
Posted by: Christopher S. Penn in: Technology, Twitter
The Mac’s Terminal is the UNIX command line. It’s hard core, the stuff that Apple actually tries to keep away from the casual user. It’s the direct line to the heart of the machine, and it’s where cool scripting action can occur. Here’s how to set it up so that with a couple of key strokes, you can send a Twitter absurdly fast. You’ll need to have curl compiled and installed on your Mac as a prerequisite.
1. Copy this script to a text file named twit.sh:
#!/bin/bash curl -u twitterusername:twitterpassword -d status="$1" http://twitter.com/statuses/update.xml
Obviously, substitute twitterusername and twitterpassword for your credentials.
2. Open Terminal and sudo chmod this file to 777.
3. Copy it to your home directory or put the location in your path.
4. Next, open up your bashrc file, which on the Mac is located at /etc/bashrc - note that you’ll have to either chmod it (bad) or sudo pico / sudo nano it to save your changes.
5. Set up an alias for the twitter script:
alias tw="/Users/yourmacusername/twit.sh"
6. Close and quit Terminal, then relaunch it. If you plan on using this a lot, you’ll probably want to put Terminal in your Dock, if it’s not there already.
7. Pop open terminal and type:
tw “Testing twitter from the command line!”
8. Check your twitter page to ensure your Tweet posted.
Popularity: 14% [?]
11 Responses
Daniel Johnson, Jr.
01|Jun|2007 1Anyone know if this or something similar works in windows?
Chris Brogan...
01|Jun|2007 2That’s for outbound, right? Is there a way to “tail the log” and watch realtime status come IN?
Andrew Pennebaker
14|Jun|2007 3Thanks! I added the silent option and sent the stdout text to heck:
#!/usr/bin/env sh
curl -u yourusername -d status=”$1″ -s -o /dev/null http://twitter.com/statuses/update.xml
carlos
08|Jan|2008 4Hi,
I work with ubuntu 7.10
I’ve follow the steps but when I type in the terminal:
tw
and ask for my host password I enter my twitter pass, but it says:
Couldn’t resolve host
The host pass and the twitter pass are different?
Thanks
carlos
08|Jan|2008 5Now, works fine. I don’t know what’s happened.
Only to add the script works in gnu/linux OS too
Regards
Murphy Mac
05|Apr|2008 6Does this not work with the curl that ships with Leopard? I left my password out of the command, was prompted for it, but my post didn’t appear. I saw the html go by.
Cool. I’ll be looking into Chris Brogan’s question. I’m definitely interested in seeing Tweets in the Terminal.
Christopher S. Penn
06|Apr|2008 7Dunno - as a rule, I typically compile major packages I know I’m going to use from source. That’s a me oddity
crimeboy
16|Apr|2008 8to improve that, and use without commas i make it
crimeboy@groselia:~$ cat twi
#!/bin/bash
# requires curl
###########################
######## CONFIG
USER=YOULOGIN
PASS=YOURPASS
URL=”http://twitter.com/statuses/update.xml”
###############
curl -u $USER:$PASS -d status=”$*” -s -o /dev/null ${URL}
Jesse
18|Apr|2008 9Hello,
I like you script, its simple and sweet. I only have to say that its probably not a good idea to advise people to chmod something to 777. This would enable other users (who would have access to your machine or network) to see not only the password which is hard coded in the script, but to change the script and insert something malicious. Perhaps something a bit more conservative like 700 would be a better choice. This value would mean that the owner (you) has read, write and execute permissions on the file, but no one else. I know you probably, and rightfully trust the people on your network, but hey–its the same amount of typing and you get free security :).
Kind Regards,
Jesse
Bonnie
07|May|2008 10This looks great. I don’t know anything about compiling commands so I tried the curl that comes with OS X. When I try this only the content up to my first space is posted on Twitter. Do you think that’s my curl or is there something else you think it might be?
Bonnie
08|May|2008 11Huh, my quotes looked funny around the $1 - I created the text file using the cat command. Fixed the quotes with pico, they look right now, and it works. Thanks.
Leave a reply
Search
Get this blog by email!
Where I'll Be
Recent Posts
Photos
Full Disclosure
Recent Comments
Archives
2
Also Me
Friends
Categories
Tags
Bank of America Blackstone Group Business Citibank dayoftheninja day of the ninja dc Economy employment fairy tale goldilocks Google Google Reader Hubspot Internet marketing invites JC Flowers JPMorgan Chase Marketing Martial arts Mashable New media New York nonprofit pab08 pab2008 PodCamp podcampdc Politics Promotion Sales Sallie Mae search engine optimization seo SLM Corporation snapple Social media taxes Twitter United States User Web Design and Development Web search engine Website WordPressA design creation of Design Disease
Copyright © 2007 - Christopher S. Penn’s Awaken Your Superhero. All rights reserved unless designated with a specific license. Comment policy: this is my blog. I do with it what I like, including your comments. This blog is powered by WordPress
InSense 1.0 Theme by Design Disease.