<?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>Living &#187; Programming</title>
	<atom:link href="http://mattsprinsky.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattsprinsky.com/blog</link>
	<description>The life of a photographer, artist, sysadmin, explorer and backyard philosopher.</description>
	<lastBuildDate>Sun, 23 May 2010 06:12:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Expect and Cadaver to automate WebDAV uploads (w\ example script)</title>
		<link>http://mattsprinsky.com/blog/2009/02/13/using-expect-and-cadaver-to-automate-webdav-uploads/</link>
		<comments>http://mattsprinsky.com/blog/2009/02/13/using-expect-and-cadaver-to-automate-webdav-uploads/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 22:24:05 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wage Slavery]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://mattsprinsky.com/blog/?p=168</guid>
		<description><![CDATA[
DISCLAIMER: I still hate windows. 
I spent a decent portion of today hunting around for a way to script or otherwise automate (at the command line) uploading a file to one of $wageslavery&#8217;s external vendors.  After diddling with curl -T only to find that it only works if the destination file doesn&#8217;t exist, I [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://mattsprinsky.com/blog/wp-content/uploads/2009/02/expect1.png" alt="" title="Expect Screenshot with sensitive data osbcured" width="500" height="247" class="aligncenter size-full wp-image-174" /></p>
<p><strong>DISCLAIMER: </strong>I still hate windows. </p>
<p>I spent a decent portion of today hunting around for a way to script or otherwise automate (at the command line) uploading a file to one of $wageslavery&#8217;s external vendors.  After diddling with curl -T only to find that it only works if the destination file doesn&#8217;t exist, I finally bit the bullet and installed <a href="http://www.cygwin.com/">Cygwin</a>. Cygwin provides a win32 version of <em>expect</em>, the command line automation tool and <em>cadaver</em>, the command line WebDAV utility, basically smbclient for WebDAV. Working example code after the break!<br />
<span id="more-168"></span><br />
The script is applicable to any platform really, but what&#8217;s below on *nix platforms may or may not require the &#8220;\n&#8221; at the end of the send statements.  <em>expect</em> sends &#8220;\r&#8221; at the end of the line by itself, and I suspect the Cygwin *nix utils running on Windows instead of *nix is probably the cause.</p>
<p>A practical, santized, example including dealing with a self-signed certificate:<br />
<code>spawn /usr/bin/cadaver https://upload.externalvendor.com/myuploads<br />
expect "Do you wish to accept the certificate"<br />
send "y\n"<br />
expect "Username:"<br />
send "starbuck\n"<br />
expect "Password:"<br />
send "0mgBACON\n"<br />
expect "dav:"<br />
send "lcd /path/to/data/files\n"<br />
expect "dav:"<br />
send "rm datafile.csv\n"<br />
expect "dav:"<br />
send "put datafile.csv\n"<br />
expect "dav:"<br />
send "quit\n"</code></p>
<p>Hopefully this helps some other poor soul stuck dealing with WebDAV uploads instead of proper sftp!</p>
<p><em>Update 2009-02-24: I added the word &#8220;script&#8221; a few times to help the Google search results. Maybe I&#8217;ll be #1 on &#8220;cadaver expect script&#8221;!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mattsprinsky.com/blog/2009/02/13/using-expect-and-cadaver-to-automate-webdav-uploads/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
