<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Irrelevant is my relevant ... &#187; Projects</title>
	<atom:link href="http://www.barkered.com/category/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barkered.com</link>
	<description></description>
	<lastBuildDate>Sun, 11 Dec 2011 17:34:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Pandemonium &#8211; Themeable Sound Board Touch Diamond Smartphone</title>
		<link>http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/</link>
		<comments>http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 11:07:26 +0000</pubDate>
		<dc:creator>barkered</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Touch Diamond]]></category>
		<category><![CDATA[Roy Walker]]></category>
		<category><![CDATA[Sound board]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Woohoo]]></category>

		<guid isPermaLink="false">http://www.barkered.com/?p=248</guid>
		<description><![CDATA[Hi, Well I have finally got round to finishing enough of this application to give you a version. Unfortunately all the features I wanted to release are not there but its close enough. Future versions will incorporate these. This application is basically a sound board with the ability to add user created content. As before, [...]]]></description>
			<content:encoded><![CDATA[<p><!-- / icon and title --> <!-- message --> Hi, Well I have finally got round to finishing enough of this application to give you a version. Unfortunately all the features I wanted to release are not there but its close enough. Future versions will incorporate these.</p>
<p><strong>This application is basically a sound board with the ability to add user created content.</strong></p>
<p>As before, requires .Net 3.5 CF.</p>
<p>The sample sound themes included in the application are a little weak and could do with some extra ones being created. Post your creations in the thread please <img class="inlineimg" title="Smile" src="http://forum.xda-developers.com/images/smilies/smile.gif" border="0" alt="" /></p>
<p>There are two types of themes available, a button theme and an image theme.</p>
<p>The button theme uses positionable windows image buttons to play the sounds.</p>
<p>The image theme uses an image to play the sounds. So for example you would have 2 images one for the background on the application for the user to see and one for the application to use. The overlay image will contain a single block of colour where you want to place a button, this colour is then indexed in the themes XML file. So when you press down on the background the colours are matched and the matching sound played.</p>
<p>The best way to get to grips with the themes is to look at two of the themes I have provided. The XML files are fully commented and quite simple to understand.</p>
<p><strong>Example of ButtonTheme, \content\Roy Walker\RoyWalker.xml<br />
Example of Imagetheme,  \content\Mr T\MRT.xml<br />
</strong></p>
<p>I am sure there will be bugs, but I wanted to get a release out as soon as possible to get some user created content. Please post any creations on this thread and I will include them in the .cab file with the next version.</p>
<p>Any feedback or suggestions please post on this thread also.</p>
<p>Future features:<br />
Volume Control<br />
More audio support, e.g. mp3 etc<br />
Options to save last theme and other stuff<br />
visual feedback on an Imagetheme button press, perhaps a greying of an area (Simple but havent had the time)</p>
<p>Any way have fun!!<br />
<a href=" http://www.barkered.com/?download=Pandemonium%20V0.1 ">Download</a></p>

<a href='http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/screen02/' title='screen02'><img width="150" height="150" src="http://www.barkered.com/wp-content/uploads/2008/09/screen02-150x150.png" class="attachment-thumbnail" alt="screen02" title="screen02" /></a>
<a href='http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/screen03/' title='screen03'><img width="150" height="150" src="http://www.barkered.com/wp-content/uploads/2008/09/screen03-150x150.png" class="attachment-thumbnail" alt="screen03" title="screen03" /></a>
<a href='http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/screen04/' title='screen04'><img width="150" height="150" src="http://www.barkered.com/wp-content/uploads/2008/09/screen04-150x150.png" class="attachment-thumbnail" alt="screen04" title="screen04" /></a>
<a href='http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/screen05/' title='screen05'><img width="150" height="150" src="http://www.barkered.com/wp-content/uploads/2008/09/screen05-150x150.png" class="attachment-thumbnail" alt="screen05" title="screen05" /></a>

<p><a href="http://www.barkered.com/wp-content/uploads/2008/09/screen05.png"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.barkered.com/2008/09/14/pandemonium-themeable-sound-board-touch-diamond-smartphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ICamViewProxy &#8211; ICamView ZoneMinder MJPEG Server pda.cgi</title>
		<link>http://www.barkered.com/2008/04/07/icamviewproxy-icamview/</link>
		<comments>http://www.barkered.com/2008/04/07/icamviewproxy-icamview/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 13:29:25 +0000</pubDate>
		<dc:creator>barkered</dc:creator>
				<category><![CDATA[ICamView]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[ICamViewProxy]]></category>
		<category><![CDATA[pda.cgi]]></category>
		<category><![CDATA[ZoneMinder]]></category>

		<guid isPermaLink="false">http://www.barkered.com/?p=198</guid>
		<description><![CDATA[ICamViewProxy has been updated. I have purchased a ICamView Plus web server and compatible Infrared camera. These devices are relatively well built and the 2 together cost me as little as £40. They are certainly not the best cameras in the world, but for that price the image quality and the functionality offered by the [...]]]></description>
			<content:encoded><![CDATA[<p><a title="ICamView Camera" href="http://www.barkered.com/wp-content/uploads/2007/12/cam.gif"><img src="http://www.barkered.com/wp-content/uploads/2007/12/cam.gif" alt="ICamView Camera" /></a><a title="ICamView Web Server" href="http://www.barkered.com/wp-content/uploads/2007/12/icamview.gif"><img src="http://www.barkered.com/wp-content/uploads/2007/12/icamview.gif" alt="ICamView Web Server" /></a></p>
<p><span style="text-decoration: underline;"><em>ICamViewProxy has been updated.</em></span></p>
<p>I have purchased a  ICamView Plus web server and compatible Infrared camera. These devices are relatively well built and the 2 together cost me as little as £40.</p>
<p>They are certainly not the best cameras in the world, but for that price the image quality and the functionality offered by the web server are very impressive.</p>
<p>The web server offers the following main features:</p>
<ul>
<li> Motion Detection</li>
<li>Scheduled Recording</li>
<li>Remote web interface</li>
<li>SNMP</li>
<li>Email and FTP alerting / uploading</li>
<li>Multiple user accounts. I.E. view only, admin</li>
<li>Single image URL (not MJPEG explained in more detail below)</li>
<li>Video streaming port (proprietary explained in more detail below)</li>
</ul>
<p>All sounds very good and for the price and it is. For myself though the image processing is overly simply and the only &#8216;tweaking&#8217; parameter is a percentage of sensitivity. Which is pretty pointless and useless. Ideally I would like to be able to monitor a single &#8216;zone&#8217; and ignore motion detection outside the zone.</p>
<p>My next step was to try and connect this IP Camera into zoneminder to give me the motion detection and alerting system I required. Simple I assumed.. How wrong I was.</p>
<h3>Image URL</h3>
<p>The single image URL provided by the web server is appallingly unreliable. Request an image via the constructed URL and sometimes get a JPEG, sometimes an error and often nothing.</p>
<p><em>http://IPADDRESS:VIDEOPORT/pda.cgi?user=&amp;password=&amp;page=image&amp;cam=1 </em></p>
<p><em>&#8216;user=&#8217;</em> is an anonymous viewer</p>
<p><em>&#8216;user=admin&#8217;</em> would be an admin user</p>
<p>similar goes for <em>&#8216;password=&#8217;</em></p>
<h3>Video Port</h3>
<p>Unfortunately the video port is a proprietary authenticated protocol based on UDP, not a MJPEG stream. I cannot understand the logic here, it would make far more sense to provide an MJPEG stream.</p>
<p>To connect to zone minder an MJPEG stream is required. This is where my proxy application comes in.</p>
<p>After a bit of googling, some reverse engineering of the protocol using <a href="http://www.wireshark.org">wireshark </a>to capture the packets sent from the windows application to the web server and some coding I have a working solution which logs into the web server video port and requests an image  every 1000/FPS ms. I found Neil Raymond&#8217;s application a great starting point. So if you are reading this, thank you!</p>
<p>The application sits on the box running zoneminder and provides a proxy between the proprietary video port and provides an MJPEG stream to zoneminder. In an ideal world, ICamView would make a complient port, but given their releases of updates it seems unlikely.</p>
<p>The application is fully portable and has been written using C++, <a href="http://www.libsdl.org/">SDL</a> and <a href="http://www.libsdl.org/projects/SDL_net/">SDL_net</a> extension. I have compiled and tested it in windows and Linux (Fedora 6). There is no reason why this should not work on any other platform.</p>
<h3>Usage Instructions:</h3>
<p>Simple really:</p>
<p><strong>ICamViewProxy -camid 1 -camhost 192.168.1.3 -camport 9001 -camuser user -campass password -proxyport 8888</strong></p>
<h3>Download</h3>
<p>The source is working source and as such may not be considered production code. This could be easily turned into a daemon with an init script in Linux.</p>
<p>This will happily cross compile, the zip file contains a working windows binary and also the required dependencies for windows compilation. This should build out of the box on visual studio 2008.</p>
<p><a href="http://www.barkered.com/?download=ICamViewProxySrc">Source Code and Win32 Binary</a></p>
<p>ICamViewProxy has been placed onto GitHub for further development, feel free to send me patches.</p>
<p><a href="http://github.com/boreddead/ICamViewProxy">ICamViewProxy on GitHub</a></p>
<p>Any questions, bugs, suggestions feel free to get in contact.</p>
<h3>Setup in ZoneMinder</h3>
<h4>Camera Type:</h4>
<p><a title="ICamView Proxy Zoneminder 1" href="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy1.jpg"><img src="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy1.jpg" alt="ICamView Proxy Zoneminder 1" /></a></p>
<h4>Source Settings:</h4>
<p><a title="ICamView Proxy Zoneminder 2" href="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy2.JPG"><img src="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy2.JPG" alt="ICamView Proxy Zoneminder 2" /></a></p>
<h4>Buffers:</h4>
<p><a title="ICamView Proxy Zoneminder 3" href="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy3.JPG"><img src="http://www.barkered.com/wp-content/uploads/2007/12/icamviewproxy3.JPG" alt="ICamView Proxy Zoneminder 3" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.barkered.com/2008/04/07/icamviewproxy-icamview/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Linux MP3 ID3 Tag Sorting Script</title>
		<link>http://www.barkered.com/2008/02/09/linux-mp3-id3-tag-sorting-script/</link>
		<comments>http://www.barkered.com/2008/02/09/linux-mp3-id3-tag-sorting-script/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 11:32:37 +0000</pubDate>
		<dc:creator>barkered</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[ID3]]></category>
		<category><![CDATA[MP3]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Sorting]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.barkered.com/?p=200</guid>
		<description><![CDATA[This is old code and quite a &#8216;hack&#8217;. It worked for my purposes so development unfortunately stopped after the task was completed. On my linux server I had a directory of unsorted music files. I like my music to be organised by folders, for example: %artist%\%album%\*.mp3 &#8211; Death\Scream Bloody Gore\ So I began writing a [...]]]></description>
			<content:encoded><![CDATA[<p>This is old code and quite a &#8216;hack&#8217;. It worked for my purposes so development unfortunately stopped after the task was completed.</p>
<p>On my linux server I had a directory of unsorted music files. I like my music to be organised by folders, for example:</p>
<p>%artist%\%album%\*.mp3 &#8211; Death\Scream Bloody Gore\</p>
<p>So I began writing a simple C++ program to read the artist and album tags from the files, create and move the files into the correct structure.</p>
<p>This is a relatively simple task and I know C++ is not the best choice of language but I thought I would continue and see how the development of C++ within Linux would fair. Mainly from a libraries point of view and an IDE.</p>
<p>Trying to find an IDE which would do code auto completion was a task which proved difficult. KDevelop seemed bloated and unusable. I settled on using a simple code editor called codeblocks. Simple, effective and easy to use.</p>
<p>Next task was to either write a library to read tags from the files or find a suitable library.</p>
<p><a href="http://developer.kde.org/~wheeler/taglib.html">http://developer.kde.org/~wheeler/taglib.html </a></p>
<p>Was my choice, a simple generic interface for multiple music files. Quite nice.</p>
<p>So I set about writing the file, here are my results:</p>
<p><a href="http://www.barkered.com/wp-content/uploads/2007/02/mp3_sorter.zip" title="Private: mp3_sorter.zip">mp3_sorter.zip</a></p>
<p>The archive contains 3 files, the .cpp file, a simple Readme file and an sh build command.</p>
<p>To build the mp3_sorter.cpp might require you to change the include paths at the top of the file.</p>
<p>Below is the command used to build, note the taglib-config part, it automatically adds the includes and linker options for taglib.</p>
<p><strong>g++ mp3_sorter.cpp -Wno-deprecated `taglib-config &#8211;cflags &#8211;libs` -o mp3_sorter</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.barkered.com/2008/02/09/linux-mp3-id3-tag-sorting-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Curl Scripting</title>
		<link>http://www.barkered.com/2008/02/07/curl-scripting/</link>
		<comments>http://www.barkered.com/2008/02/07/curl-scripting/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 20:23:52 +0000</pubDate>
		<dc:creator>barkered</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Curl]]></category>
		<category><![CDATA[Curl Scripting]]></category>
		<category><![CDATA[Post Scripting]]></category>

		<guid isPermaLink="false">http://www.barkered.com/?p=199</guid>
		<description><![CDATA[This article was not written by myself, I copied and pasted it from the internet. Therefore I am not claiming this is my own work. The Art Of Scripting HTTP Requests Using Curl ============================================= This document will assume that you&#8217;re familiar with HTML and general networking. The possibility to write scripts is essential to make [...]]]></description>
			<content:encoded><![CDATA[<p style="font-weight: bold;" align="justify">This article was not written by myself, I copied and pasted it from the internet. Therefore I am not claiming this is my own work.</p>
<p align="left">
<div>
<p>The Art Of Scripting HTTP Requests Using Curl</p>
<p>=============================================</p>
<p>This document will assume that you&#8217;re familiar with HTML and general<br />
networking.</p>
<p>The possibility to write scripts is essential to make a good computer<br />
system. Unix&#8217; capability to be extended by shell scripts and various tools to<br />
run various automated commands and scripts is one reason why it has succeeded<br />
so well.</p>
<p>The increasing amount of applications moving to the web has made &#8220;HTTP<br />
Scripting&#8221; more frequently requested and wanted. To be able to automatically<br />
extract information from the web, to fake users, to post or upload data to<br />
web servers are all important tasks today.</p>
<p>Curl is a command line tool for doing all sorts of URL manipulations and<br />
transfers, but this particular document will focus on how to use it when<br />
doing HTTP requests for fun and profit. I&#8217;ll assume that you know how to<br />
invoke &#8216;curl &#8211;help&#8217; or &#8216;curl &#8211;manual&#8217; to get basic information about it.</p>
<p>Curl is not written to do everything for you. It makes the requests, it gets<br />
the data, it sends data and it retrieves the information. You probably need<br />
to glue everything together using some kind of script language or repeated<br />
manual invokes.</p>
<p>1. The HTTP Protocol</p>
<p>HTTP is the protocol used to fetch data from web servers. It is a very simple<br />
protocol that is built upon TCP/IP. The protocol also allows information to<br />
get sent to the server from the client using a few different methods, as will<br />
be shown here.</p>
<p>HTTP is plain ASCII text lines being sent by the client to a server to<br />
request a particular action, and then the server replies a few text lines<br />
before the actual requested content is sent to the client.</p>
<p>Using curl&#8217;s option -v will display what kind of commands curl sends to the<br />
server, as well as a few other informational texts. -v is the single most<br />
useful option when it comes to debug or even understand the curl&lt;-&gt;server<br />
interaction.</p>
<p>2. URL</p>
<p>The Uniform Resource Locator format is how you specify the address of a<br />
particular resource on the Internet. You know these, you&#8217;ve seen URLs like<br />
http://curl.haxx.se or https://yourbank.com a million times.</p>
<p>3. GET a page</p>
<p>The simplest and most common request/operation made using HTTP is to get a<br />
URL. The URL could itself refer to a web page, an image or a file. The client<br />
issues a GET request to the server and receives the document it asked for.<br />
If you issue the command line</p>
<p>curl http://curl.haxx.se</p>
<p>you get a web page returned in your terminal window. The entire HTML document<br />
that that URL holds.</p>
<p>All HTTP replies contain a set of headers that are normally hidden, use<br />
curl&#8217;s -i option to display them as well as the rest of the document. You can<br />
also ask the remote server for ONLY the headers by using the -I option (which<br />
will make curl issue a HEAD request).</p>
<p>4. Forms</p>
<p>Forms are the general way a web site can present a HTML page with fields for<br />
the user to enter data in, and then press some kind of &#8216;OK&#8217; or &#8216;submit&#8217;<br />
button to get that data sent to the server. The server then typically uses<br />
the posted data to decide how to act. Like using the entered words to search<br />
in a database, or to add the info in a bug track system, display the entered<br />
address on a map or using the info as a login-prompt verifying that the user<br />
is allowed to see what it is about to see.</p>
<p>Of course there has to be some kind of program in the server end to receive<br />
the data you send. You cannot just invent something out of the air.</p>
<p>4.1 GET</p>
<p>A GET-form uses the method GET, as specified in HTML like:</p>
<p>&lt;form method=&#8221;GET&#8221; action=&#8221;junk.cgi&#8221;&gt;<br />
&lt;input type=text name=&#8221;birthyear&#8221;&gt;<br />
&lt;input type=submit name=press value=&#8221;OK&#8221;&gt;<br />
&lt;/form&gt;</p>
<p>In your favorite browser, this form will appear with a text box to fill in<br />
and a press-button labeled &#8220;OK&#8221;. If you fill in &#8217;1905&#8242; and press the OK<br />
button, your browser will then create a new URL to get for you. The URL will<br />
get &#8220;junk.cgi?birthyear=1905&amp;press=OK&#8221; appended to the path part of the<br />
previous URL.</p>
<p>If the original form was seen on the page &#8220;www.hotmail.com/when/birth.html&#8221;,<br />
the second page you&#8217;ll get will become<br />
&#8220;www.hotmail.com/when/junk.cgi?birthyear=1905&amp;press=OK&#8221;.</p>
<p>Most search engines work this way.</p>
<p>To make curl do the GET form post for you, just enter the expected created<br />
URL:</p>
<p>curl &#8220;www.hotmail.com/when/junk.cgi?birthyear=1905&amp;press=OK&#8221;</p>
<p>4.2 POST</p>
<p>The GET method makes all input field names get displayed in the URL field of<br />
your browser. That&#8217;s generally a good thing when you want to be able to<br />
bookmark that page with your given data, but it is an obvious disadvantage<br />
if you entered secret information in one of the fields or if there are a<br />
large amount of fields creating a very long and unreadable URL.</p>
<p>The HTTP protocol then offers the POST method. This way the client sends the<br />
data separated from the URL and thus you won&#8217;t see any of it in the URL<br />
address field.</p>
<p>The form would look very similar to the previous one:</p>
<p>&lt;form method=&#8221;POST&#8221; action=&#8221;junk.cgi&#8221;&gt;<br />
&lt;input type=text name=&#8221;birthyear&#8221;&gt;<br />
&lt;input type=submit name=press value=&#8221; OK &#8220;&gt;<br />
&lt;/form&gt;</p>
<p>And to use curl to post this form with the same data filled in as before, we<br />
could do it like:</p>
<p>curl -d &#8220;birthyear=1905&amp;press=%20OK%20&#8243; www.hotmail.com/when/junk.cgi</p>
<p>This kind of POST will use the Content-Type<br />
application/x-www-form-urlencoded and is the most widely used POST kind.</p>
<p>The data you send to the server MUST already be properly encoded, curl will<br />
not do that for you. For example, if you want the data to contain a space,<br />
you need to replace that space with %20 etc. Failing to comply with this<br />
will most likely cause your data to be received wrongly and messed up.</p>
<p>4.3 File Upload POST</p>
<p>Back in late 1995 they defined an additional way to post data over HTTP. It<br />
is documented in the RFC 1867, why this method sometimes is referred to as<br />
RFC1867-posting.</p>
<p>This method is mainly designed to better support file uploads. A form that<br />
allows a user to upload a file could be written like this in HTML:</p>
<p>&lt;form method=&#8221;POST&#8221; enctype=&#8217;multipart/form-data&#8217; action=&#8221;upload.cgi&#8221;&gt;<br />
&lt;input type=file name=upload&gt;<br />
&lt;input type=submit name=press value=&#8221;OK&#8221;&gt;<br />
&lt;/form&gt;</p>
<p>This clearly shows that the Content-Type about to be sent is<br />
multipart/form-data.</p>
<p>To post to a form like this with curl, you enter a command line like:</p>
<p>curl -F upload=@localfilename -F press=OK [URL]</p>
<p>4.4 Hidden Fields</p>
<p>A very common way for HTML based application to pass state information<br />
between pages is to add hidden fields to the forms. Hidden fields are<br />
already filled in, they aren&#8217;t displayed to the user and they get passed<br />
along just as all the other fields.</p>
<p>A similar example form with one visible field, one hidden field and one<br />
submit button could look like:</p>
<p>&lt;form method=&#8221;POST&#8221; action=&#8221;foobar.cgi&#8221;&gt;<br />
&lt;input type=text name=&#8221;birthyear&#8221;&gt;<br />
&lt;input type=hidden name=&#8221;person&#8221; value=&#8221;daniel&#8221;&gt;<br />
&lt;input type=submit name=&#8221;press&#8221; value=&#8221;OK&#8221;&gt;<br />
&lt;/form&gt;</p>
<p>To post this with curl, you won&#8217;t have to think about if the fields are<br />
hidden or not. To curl they&#8217;re all the same:</p>
<p>curl -d &#8220;birthyear=1905&amp;press=OK&amp;person=daniel&#8221; [URL]</p>
<p>4.5 Figure Out What A POST Looks Like</p>
<p>When you&#8217;re about fill in a form and send to a server by using curl instead<br />
of a browser, you&#8217;re of course very interested in sending a POST exactly the<br />
way your browser does.</p>
<p>An easy way to get to see this, is to save the HTML page with the form on<br />
your local disk, modify the &#8216;method&#8217; to a GET, and press the submit button<br />
(you could also change the action URL if you want to).</p>
<p>You will then clearly see the data get appended to the URL, separated with a<br />
&#8216;?&#8217;-letter as GET forms are supposed to.</p>
<p>5. PUT</p>
<p>The perhaps best way to upload data to a HTTP server is to use PUT. Then<br />
again, this of course requires that someone put a program or script on the<br />
server end that knows how to receive a HTTP PUT stream.</p>
<p>Put a file to a HTTP server with curl:</p>
<p>curl -T uploadfile www.uploadhttp.com/receive.cgi</p>
<p>6. Authentication</p>
<p>Authentication is the ability to tell the server your username and password<br />
so that it can verify that you&#8217;re allowed to do the request you&#8217;re doing. The<br />
Basic authentication used in HTTP (which is the type curl uses by default) is<br />
*plain* *text* based, which means it sends username and password only<br />
slightly obfuscated, but still fully readable by anyone that sniffs on the<br />
network between you and the remote server.</p>
<p>To tell curl to use a user and password for authentication:</p>
<p>curl -u name:password www.secrets.com</p>
<p>The site might require a different authentication method (check the headers<br />
returned by the server), and then &#8211;ntlm, &#8211;digest, &#8211;negotiate or even<br />
&#8211;anyauth might be options that suit you.<br />
Sometimes your HTTP access is only available through the use of a HTTP<br />
proxy. This seems to be especially common at various companies. A HTTP proxy<br />
may require its own user and password to allow the client to get through to<br />
the Internet. To specify those with curl, run something like:</p>
<p>curl -U proxyuser:proxypassword curl.haxx.se</p>
<p>If your proxy requires the authentication to be done using the NTLM method,<br />
use &#8211;proxy-ntlm, if it requires Digest use &#8211;proxy-digest.</p>
<p>If you use any one these user+password options but leave out the password<br />
part, curl will prompt for the password interactively.</p>
<p>Do note that when a program is run, its parameters might be possible to see<br />
when listing the running processes of the system. Thus, other users may be<br />
able to watch your passwords if you pass them as plain command line<br />
options. There are ways to circumvent this.</p>
<p>7. Referer</p>
<p>A HTTP request may include a &#8216;referer&#8217; field (yes it is misspelled), which<br />
can be used to tell from which URL the client got to this particular<br />
resource. Some programs/scripts check the referer field of requests to verify<br />
that this wasn&#8217;t arriving from an external site or an unknown page. While<br />
this is a stupid way to check something so easily forged, many scripts still<br />
do it. Using curl, you can put anything you want in the referer-field and<br />
thus more easily be able to fool the server into serving your request.</p>
<p>Use curl to set the referer field with:</p>
<p>curl -e http://curl.haxx.se daniel.haxx.se</p>
<p>8. User Agent</p>
<p>Very similar to the referer field, all HTTP requests may set the User-Agent<br />
field. It names what user agent (client) that is being used. Many<br />
applications use this information to decide how to display pages. Silly web<br />
programmers try to make different pages for users of different browsers to<br />
make them look the best possible for their particular browsers. They usually<br />
also do different kinds of javascript, vbscript etc.</p>
<p>At times, you will see that getting a page with curl will not return the same<br />
page that you see when getting the page with your browser. Then you know it<br />
is time to set the User Agent field to fool the server into thinking you&#8217;re<br />
one of those browsers.</p>
<p>To make curl look like Internet Explorer on a Windows 2000 box:</p>
<p>curl -A &#8220;Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)&#8221; [URL]</p>
<p>Or why not look like you&#8217;re using Netscape 4.73 on a Linux (PIII) box:</p>
<p>curl -A &#8220;Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)&#8221; [URL]</p>
<p>9. Redirects</p>
<p>When a resource is requested from a server, the reply from the server may<br />
include a hint about where the browser should go next to find this page, or a<br />
new page keeping newly generated output. The header that tells the browser<br />
to redirect is Location:.</p>
<p>Curl does not follow Location: headers by default, but will simply display<br />
such pages in the same manner it display all HTTP replies. It does however<br />
feature an option that will make it attempt to follow the Location: pointers.</p>
<p>To tell curl to follow a Location:<br />
curl -L www.sitethatredirects.com</p>
<p>If you use curl to POST to a site that immediately redirects you to another<br />
page, you can safely use -L and -d/-F together. Curl will only use POST in<br />
the first request, and then revert to GET in the following operations.</p>
<p>10. Cookies</p>
<p>The way the web browsers do &#8220;client side state control&#8221; is by using<br />
cookies. Cookies are just names with associated contents. The cookies are<br />
sent to the client by the server. The server tells the client for what path<br />
and host name it wants the cookie sent back, and it also sends an expiration<br />
date and a few more properties.</p>
<p>When a client communicates with a server with a name and path as previously<br />
specified in a received cookie, the client sends back the cookies and their<br />
contents to the server, unless of course they are expired.</p>
<p>Many applications and servers use this method to connect a series of requests<br />
into a single logical session. To be able to use curl in such occasions, we<br />
must be able to record and send back cookies the way the web application<br />
expects them. The same way browsers deal with them.</p>
<p>The simplest way to send a few cookies to the server when getting a page with<br />
curl is to add them on the command line like:</p>
<p>curl -b &#8220;name=Daniel&#8221; www.cookiesite.com</p>
<p>Cookies are sent as common HTTP headers. This is practical as it allows curl<br />
to record cookies simply by recording headers. Record cookies with curl by<br />
using the -D option like:</p>
<p>curl -D headers_and_cookies www.cookiesite.com</p>
<p>(Take note that the -c option described below is a better way to store<br />
cookies.)</p>
<p>Curl has a full blown cookie parsing engine built-in that comes to use if you<br />
want to reconnect to a server and use cookies that were stored from a<br />
previous connection (or handicrafted manually to fool the server into<br />
believing you had a previous connection). To use previously stored cookies,<br />
you run curl like:</p>
<p>curl -b stored_cookies_in_file www.cookiesite.com</p>
<p>Curl&#8217;s &#8220;cookie engine&#8221; gets enabled when you use the -b option. If you only<br />
want curl to understand received cookies, use -b with a file that doesn&#8217;t<br />
exist. Example, if you want to let curl understand cookies from a page and<br />
follow a location (and thus possibly send back cookies it received), you can<br />
invoke it like:</p>
<p>curl -b nada -L www.cookiesite.com</p>
<p>Curl has the ability to read and write cookie files that use the same file<br />
format that Netscape and Mozilla do. It is a convenient way to share cookies<br />
between browsers and automatic scripts. The -b switch automatically detects<br />
if a given file is such a cookie file and parses it, and by using the<br />
-c/&#8211;cookie-jar option you&#8217;ll make curl write a new cookie file at the end of<br />
an operation:</p>
<p>curl -b cookies.txt -c newcookies.txt www.cookiesite.com</p>
<p>11. HTTPS</p>
<p>There are a few ways to do secure HTTP transfers. The by far most common<br />
protocol for doing this is what is generally known as HTTPS, HTTP over<br />
SSL. SSL encrypts all the data that is sent and received over the network and<br />
thus makes it harder for attackers to spy on sensitive information.</p>
<p>SSL (or TLS as the latest version of the standard is called) offers a<br />
truckload of advanced features to allow all those encryptions and key<br />
infrastructure mechanisms encrypted HTTP requires.</p>
<p>Curl supports encrypted fetches thanks to the freely available OpenSSL<br />
libraries. To get a page from a HTTPS server, simply run curl like:</p>
<p>curl https://that.secure.server.com</p>
<p>11.1 Certificates</p>
<p>In the HTTPS world, you use certificates to validate that you are the one<br />
you you claim to be, as an addition to normal passwords. Curl supports<br />
client-side certificates. All certificates are locked with a pass phrase,<br />
which you need to enter before the certificate can be used by curl. The pass<br />
phrase can be specified on the command line or if not, entered interactively<br />
when curl queries for it. Use a certificate with curl on a HTTPS server<br />
like:</p>
<p>curl -E mycert.pem https://that.secure.server.com</p>
<p>curl also tries to verify that the server is who it claims to be, by<br />
verifying the server&#8217;s certificate against a locally stored CA cert<br />
bundle. Failing the verification will cause curl to deny the connection. You<br />
must then use -k in case you want to tell curl to ignore that the server<br />
can&#8217;t be verified.</p>
<p>More about server certificate verification and ca cert bundles can be read<br />
in the SSLCERTS document, available online here:</p>
<p>http://curl.haxx.se/docs/sslcerts.html</p>
<p>12. Custom Request Elements</p>
<p>Doing fancy stuff, you may need to add or change elements of a single curl<br />
request.</p>
<p>For example, you can change the POST request to a PROPFIND and send the data<br />
as &#8220;Content-Type: text/xml&#8221; (instead of the default Content-Type) like this:</p>
<p>curl -d &#8220;&lt;xml&gt;&#8221; -H &#8220;Content-Type: text/xml&#8221; -X PROPFIND url.com</p>
<p>You can delete a default header by providing one without content. Like you<br />
can ruin the request by chopping off the Host: header:</p>
<p>curl -H &#8220;Host:&#8221; http://mysite.com</p>
<p>You can add headers the same way. Your server may want a &#8220;Destination:&#8221;<br />
header, and you can add it:</p>
<p>curl -H &#8220;Destination: http://moo.com/nowhere&#8221; http://url.com</p>
<p>13. Debug</p>
<p>Many times when you run curl on a site, you&#8217;ll notice that the site doesn&#8217;t<br />
seem to respond the same way to your curl requests as it does to your<br />
browser&#8217;s.</p>
<p>Then you need to start making your curl requests more similar to your<br />
browser&#8217;s requests:</p>
<p>* Use the &#8211;trace-ascii option to store fully detailed logs of the requests<br />
for easier analyzing and better understanding</p>
<p>* Make sure you check for and use cookies when needed (both reading with -b<br />
and writing with -c)</p>
<p>* Set user-agent to one like a recent popular browser does</p>
<p>* Set referer like it is set by the browser</p>
<p>* If you use POST, make sure you send all the fields and in the same order as<br />
the browser does it. (See chapter 4.5 above)</p>
<p>A very good helper to make sure you do this right, is the LiveHTTPHeader tool<br />
that lets you view all headers you send and receive with Mozilla/Firefox<br />
(even when using HTTPS).</p>
<p>A more raw approach is to capture the HTTP traffic on the network with tools<br />
such as ethereal or tcpdump and check what headers that were sent and<br />
received by the browser. (HTTPS makes this technique inefficient.)</p>
<p>14. References</p>
<p>RFC 2616 is a must to read if you want in-depth understanding of the HTTP<br />
protocol.</p>
<p>RFC 2396 explains the URL syntax.</p>
<p>RFC 2109 defines how cookies are supposed to work.</p>
<p>RFC 1867 defines the HTTP post upload format.</p>
<p>http://www.openssl.org is the home of the OpenSSL project</p>
<p>http://curl.haxx.se is the home of the cURL project</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.barkered.com/2008/02/07/curl-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

