<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: curl code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 17:14:01 GMT</pubDate>
    <description>DZone Snippets: curl code</description>
    <item>
      <title>Update DynDNS hostname</title>
      <link>http://snippets.dzone.com/posts/show/5463</link>
      <description>See DynDNS Update Specifications &lt;http://www.dyndns.com/developers/specs/syntax.html&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -v -k -u jakobm "https://members.dyndns.org/nic/update?hostname=jakobm.dyndns.org&amp;myip=217.80.116.128&amp;wildcard=NOCHG&amp;mx=NOCHG&amp;backmx=NOCHG"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 05 May 2008 19:45:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5463</guid>
      <author>jakob ()</author>
    </item>
    <item>
      <title>Finding your WAN IP address</title>
      <link>http://snippets.dzone.com/posts/show/5346</link>
      <description>My server sits behind a NAT router, so finding out my public IP address is a non-trivial task. I can use curl to poll checkip.dyndns.org for my current address:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -s checkip.dyndns.org&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The current IP check returns the information in this format: &lt;html&gt;&lt;head&gt;&lt;title&gt;Current IP Check&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Current IP Address: 216.239.39.99&lt;/body&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;Using cut, I can extract just the information that I need:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -s checkip.dyndns.org|cut -d ":" -f2|cut -d "&lt;" -f1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;That produces something a bit more readable: 216.239.39.99&lt;br /&gt;&lt;br /&gt;-------------------------&lt;br /&gt;This article snippet was copied from &lt;a href="http://www.linux.com/articles/52552"&gt;My sysadmin toolbox&lt;/a&gt; [linux.com] while I was googling for 'apt-cache search dyndns'.</description>
      <pubDate>Fri, 11 Apr 2008 09:14:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5346</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Twitter and Jaiku from the command line</title>
      <link>http://snippets.dzone.com/posts/show/5265</link>
      <description>The following instructions make it easy to post to Twitter and Jaiku from the command line. The instructions were copied from the article &lt;a href="http://snipr.com/22b38"&gt;"Ubuntu Unleashed: Howto Twitter From the Command Line in Ubuntu!"&lt;/a&gt;  [ubuntu-unleashed.com] and modified to post via Rorbuilder's ProjectX API.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;sudo apt-get install curl&lt;/code&gt;&lt;br /&gt;&lt;code&gt;sudo gedit /usr/bin/jaitwit&lt;/code&gt;&lt;br /&gt;Now Paste this in gEdit and simply replace "YourUsername" with your username and "YourPassword" with your twitter passwd, then replace the Jaiku variables (YourUsername, YourPassword, YourCity, YourAccessKey) and ctrl-s to save, then alt-F4 to exit!&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl http://rorbuilder.info/api/projectx.cgi?xml_project=%3Cproject%20name=%22micro_blog%22%3E%3Cmethods%3E%3Cmethod%20name=%22post2jaiku%22%3E%3Cparams%3E%3Cparam%20var=%22user%22%20val=%22YourUsername%22/%3E%3Cparam%20var=%22msg%22%20val=%22`echo $@|tr ' ' '+'`%22/%3E%3Cparam%20var=%22location%22%20val=%22YourCity%22/%3E%3Cparam%20var=%22apikey%22%20val=%22YourAccessKey%22/%3E%3C/params%3E%3C/method%3E%3Cmethod%20name=%22post2twitter%22%3E%3Cparams%3E%3Cparam%20var=%22user%22%20val=%22YourUsername%22/%3E%3Cparam%20var=%22msg%22%20val=%22`echo $@|tr ' ' '+'`%22/%3E%3Cparam%20var=%22password%22%20val=%22YourPassword%22/%3E%3C/params%3E%3C/method%3E%3C/methods%3E%3C/project%3E -o /dev/null&lt;br /&gt;echo Message Sent!&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then chmod for exec privileges:&lt;br /&gt;&lt;code&gt;chmod +x /usr/bin/jaitwit&lt;/code&gt;&lt;br /&gt;Then from the CLI type jaitwit followed by your message.&lt;br /&gt;&lt;code&gt;jaitwit "message here without the quotes"&lt;/code&gt;</description>
      <pubDate>Fri, 21 Mar 2008 18:28:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5265</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>FTPS upload a file from Ruby using Curl command line</title>
      <link>http://snippets.dzone.com/posts/show/4801</link>
      <description>Yes, this is lame, but I didn't have much luck with Ruby libraries, so this is what I came up with.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;`curl -k --ftp-ssl -3 -T#{path} -u#{FTP_USER}:#{FTP_PASS} #{FTP_HOST}`&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;-k forces the connection even if the cert looks bad&lt;br /&gt;-3 turns on SSLv3&lt;br /&gt;-T file to upload&lt;br /&gt;-u user:password</description>
      <pubDate>Tue, 20 Nov 2007 15:46:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4801</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Test Trackback using cURL</title>
      <link>http://snippets.dzone.com/posts/show/4540</link>
      <description>I've Googled this about 20 times - documenting it here for convenience.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -d url=TRACKBACK_URL -d title=TRACKBACK_TITLE -d blog_name=TRACKBACK_BLOG_NAME -d excerpt=TRACKBACK_EXCERPT URL&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;A correct response:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;br /&gt;&lt;response&gt;&lt;br /&gt;&lt;error&gt;0&lt;/error&gt;&lt;br /&gt;&lt;/response&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 14 Sep 2007 01:31:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4540</guid>
      <author>jnewland (Jesse Newland)</author>
    </item>
    <item>
      <title>Twitter bot weatherlisbon</title>
      <link>http://snippets.dzone.com/posts/show/4159</link>
      <description>This little bash script shows how to use curl, grep, tail, sed and perl one-liners in order to compose a bleeding-edge twitter bot.&lt;br /&gt;This one returns daily weather forecasts for Lisbon city based on the BBC weather forecast rss feed.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#! /bin/sh&lt;br /&gt;&lt;br /&gt;#Goto here&lt;br /&gt;here=/home/guillaume/Personal&lt;br /&gt;cd $here&lt;br /&gt;&lt;br /&gt;#BBC Lisbon weather id&lt;br /&gt;id=0048&lt;br /&gt;&lt;br /&gt;#BBC weather RSS feed address&lt;br /&gt;feed="http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/${id}.xml"&lt;br /&gt;&lt;br /&gt;#City&lt;br /&gt;city=lisbon&lt;br /&gt;&lt;br /&gt;#temporary file&lt;br /&gt;file="weather${city}"&lt;br /&gt;&lt;br /&gt;#Weather twitter bot&lt;br /&gt;twitbot=weatherlisbon:*******&lt;br /&gt;&lt;br /&gt;#Timestamp the log file&lt;br /&gt;echo .&gt;&gt; $file.log&lt;br /&gt;date &gt;&gt; $file.log&lt;br /&gt;&lt;br /&gt;#Read the RSS feed and filter it&lt;br /&gt;curl $feed | grep 'title' | tail -n 1 | perl -wlne'm/title&gt;(.*)&lt;\/title/i &amp;&amp; print $1' | sed -e "s/&amp;#xB0;//g" &gt; $file.txt&lt;br /&gt;&lt;br /&gt;#Read the forecast into a weather variable&lt;br /&gt;read weather &lt; $file.txt&lt;br /&gt;&lt;br /&gt;#Twit the weather variable away&lt;br /&gt;curl --basic --user $twitbot --data status="$weather" http://twitter.com/statuses/update.xml &gt;&gt; $file.log&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 18 Jun 2007 21:37:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4159</guid>
      <author>griflet (guillaume riflet)</author>
    </item>
    <item>
      <title>cURL Download</title>
      <link>http://snippets.dzone.com/posts/show/3919</link>
      <description>// function to dowload a $remote file and store as $local file, using curl&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function curl_download($remote, $local)	{&lt;br /&gt;	$cp = curl_init($remote);&lt;br /&gt;	$fp = fopen($local, "w");&lt;br /&gt;	&lt;br /&gt;	curl_setopt($cp, CURLOPT_FILE, $fp);&lt;br /&gt;	curl_setopt($cp, CURLOPT_HEADER, 0);&lt;br /&gt;	&lt;br /&gt;	curl_exec($cp);&lt;br /&gt;	curl_close($cp);&lt;br /&gt;	fclose($fp);	&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 27 Apr 2007 04:22:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3919</guid>
      <author>damonp (Damon Parker)</author>
    </item>
    <item>
      <title>REST curl helper</title>
      <link>http://snippets.dzone.com/posts/show/3521</link>
      <description>// A small bash script that wraps around curl to help more easily test RESTful sites.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;AUTH="user:password"&lt;br /&gt;BASE="http://localhost:3000"&lt;br /&gt;METHOD=$1&lt;br /&gt;DEST="$BASE$2"&lt;br /&gt;XML=$3&lt;br /&gt;&lt;br /&gt;# make sure args were passed&lt;br /&gt;if [ $# -eq 0 ]; then&lt;br /&gt;        echo "usage: ./`basename $0` HTTP-METHOD DESTINATION_URI [XML]"&lt;br /&gt;        echo "example: ./`basename $0` POST "/accounts" \"&lt;account&gt;&lt;name&gt;ed&lt;/name&gt;&lt;email&gt;ed@ed.com&lt;/email&gt;&lt;/account&gt;\""&lt;br /&gt;        exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;# execute CURL call&lt;br /&gt;curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -w '\nHTTP STATUS: %{http_code}\nTIME: %{time_total}\n' \&lt;br /&gt;-X $METHOD \&lt;br /&gt;-d "$XML" \&lt;br /&gt;-u "$AUTH" \&lt;br /&gt;"$DEST"&lt;br /&gt;&lt;br /&gt;exit 0&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 14 Feb 2007 03:39:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3521</guid>
      <author>bassnode (Ed)</author>
    </item>
    <item>
      <title>Building curb under Mac OS X</title>
      <link>http://snippets.dzone.com/posts/show/3250</link>
      <description>Had a bit of a problem getting curb to work in OS X, but if you have the curl port installed, its easy:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;sudo port install curl&lt;br /&gt;cd src&lt;br /&gt;curl -O http://rubyforge.iasi.roedu.net/files/curb/curb-0.1.0.tar.gz&lt;br /&gt;tar -zxvf curb-0.1.0.tar.gz&lt;br /&gt;cd curb-0.1.0.tar.gz&lt;br /&gt;ruby extconf.rb --with-curl-lib=/opt/local/lib/ --with-curl-include=/opt/local/include/&lt;br /&gt;ruby tests/alltests.rb&lt;br /&gt;sudo make install&lt;/pre&gt;&lt;br /&gt;</description>
      <pubDate>Sat, 06 Jan 2007 00:44:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3250</guid>
      <author>willcodeforfoo ()</author>
    </item>
    <item>
      <title>Python - simplePing</title>
      <link>http://snippets.dzone.com/posts/show/3035</link>
      <description>// Verifica se un Server e' su o giu'&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import pycurl&lt;br /&gt;&lt;br /&gt;def nullFunc(args):&lt;br /&gt;	pass&lt;br /&gt;&lt;br /&gt;try:&lt;br /&gt;&lt;br /&gt;	curl = pycurl.Curl()&lt;br /&gt;	curl.setopt(pycurl.WRITEFUNCTION, nullFunc)&lt;br /&gt;	curl.setopt(pycurl.URL, 'http://www.google.it')&lt;br /&gt;	curl.perform()&lt;br /&gt;&lt;br /&gt;	print "Server SU"&lt;br /&gt;&lt;br /&gt;except Exception, error:&lt;br /&gt;&lt;br /&gt;	print "Server GIU'"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 25 Nov 2006 19:27:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3035</guid>
      <author>whitetiger ()</author>
    </item>
  </channel>
</rss>
