I’m looking to update twitter using cURL. I’ve written a bash function, but I’m not sure how to get it to accept a line as an argument to use as status text. The current function just accepts the first word as an argument. Also, can I prevent it from returning the XML file or suppress it from going to stdout?
#!/bin/bash
function tweet {
curl -s -u username:password -d status="$1" http://twitter.com/statuses/update.xml
}
PS – I know there are other questions re: cURL and Twitter on SO but none answer my question.
Yes, and yes. In bash, you want to use $* instead of $1. To suppress anything from going to stdout, just redirect it to /dev/null. So, your code would look like:
UPDATE
As already pointed out, this will no longer work because of the changes to twitter’s authentication method. I’ll leave it here for historical reasons.