<?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>Schadenfreude &#187; scripting</title>
	<atom:link href="http://www.ralree.com/tag/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>wget mirroring with external references</title>
		<link>http://www.ralree.com/2011/12/03/wget-mirroring-with-external-references/</link>
		<comments>http://www.ralree.com/2011/12/03/wget-mirroring-with-external-references/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 05:49:32 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=23252</guid>
		<description><![CDATA[I was having trouble mirroring a website that had all its images hosted on a different domain, which happened to be random subdomains of cloudfront.net.  I tried adding *.cloudfront.net to the -D parameter, but that didn&#8217;t work.  It turns out it&#8217;s smart enough to figure out that all subdomains in the domain list should be included as well: wget -mkpEK -D www.allshepherdrescue.org,cloudfront.net -H -t 3 \ --restrict-file-names=windows http://www.allshepherdrescue.org/ This goes into mirror mode, changes relative links to the proper form, [...]]]></description>
			<content:encoded><![CDATA[<p>I was having trouble mirroring a website that had all its images hosted on a different domain, which happened to be random subdomains of cloudfront.net.  I tried adding *.cloudfront.net to the -D parameter, but that didn&#8217;t work.  It turns out it&#8217;s smart enough to figure out that all subdomains in the domain list should be included as well:</p>
<pre>wget -mkpEK -D www.allshepherdrescue.org,cloudfront.net -H -t 3 \
     --restrict-file-names=windows http://www.allshepherdrescue.org/</pre>
<p>This goes into mirror mode, changes relative links to the proper form, fixes the query string urls to static ones, and downloads all files from the domains in the -D parameter.  The manpage details all of this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2011/12/03/wget-mirroring-with-external-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding bad JPEGs with Xorg hacks in Ubuntu</title>
		<link>http://www.ralree.com/2007/11/25/finding-bad-jpegs-with-xorg-hacks-in-ubuntu/</link>
		<comments>http://www.ralree.com/2007/11/25/finding-bad-jpegs-with-xorg-hacks-in-ubuntu/#comments</comments>
		<pubDate>Sun, 25 Nov 2007 00:46:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[qiv]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/11/25/finding-bad-jpegs-with-xorg-hacks-in-ubuntu</guid>
		<description><![CDATA[So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one: Premature end of JPEG file So, this is nice, except it&#8217;s entirely unscriptable. The solution I found was using the following script to the display the images in sequence: perl -e 'for(glob("*.png *.jpg")){$output = `qiv "$_" 2&#62;&#038;1;`; if($output =~ /Premature/){print $_, "\n";}}' All this does is mix STDERR [...]]]></description>
			<content:encoded><![CDATA[<p>So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely).  <a href="http://www.klografx.net/qiv/">qiv</a> will spit out the following to <code>STDERR</code> when it finds one:</p>
<pre><code>
Premature end of JPEG file
</code></pre>
<p>So, this is nice, except it&#8217;s <strong><em>entirely unscriptable</strong></em>.  The solution I found was using the following script to the display the images in sequence:</p>
<pre><code>
perl -e 'for(glob("*.png *.jpg")){$output = `qiv "$_" 2&gt;&#038;1;`; if($output =~ /Premature/){print $_, "\n";}}'
</code></pre>
<p>All this does is mix <code>STDERR</code> with <code>STDOUT</code> for a <code>qiv</code> of the file, and check the output for the word &#8220;Premature&#8221;.  If it finds the word, it prints the filename.  Simple.</p>
<p>The only problem is that <code>qiv</code> doesnt have a way to just check whether a JPEG file is corrupt (and if there is a command line utility that does, please let me know).  To make it go thru the list, I wrote this little gem:</p>
<pre><code>
while(true); do xte "key q"; done
</code></pre>
<p>All this does is send the <code>q</code> key to the Xserver infinitely.  All I have to do is put focus on the first <code>qiv</code> window to make it and all subsequent <code>qiv</code> windows receive q&#8217;s.  So, just run it, and click on the window.  Then there are lots of flashes, and eventually that perl script will print out the names of the bad files.  It&#8217;s totally ghetto, but it&#8217;s the best I&#8217;ve got right now.  The point of this post is to hopefully find new ways to do this more programmatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/11/25/finding-bad-jpegs-with-xorg-hacks-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting EXIF dates with a loop</title>
		<link>http://www.ralree.com/2007/09/18/setting-exif-dates-with-a-loop/</link>
		<comments>http://www.ralree.com/2007/09/18/setting-exif-dates-with-a-loop/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 00:11:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[exif]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/setting-exif-dates-with-a-loop</guid>
		<description><![CDATA[Magic EXIF recursive tagging! Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates? Here&#8217;s what I used today to do it: # Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg # Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU'RE DOING!) find . -mindepth 3 -exec jhead -de "{}" \; # Make Fresh EXIF tags find . -mindepth 3 -exec jhead -mkexif "{}" \; # Set the dates according [...]]]></description>
			<content:encoded><![CDATA[<h2>Magic EXIF recursive tagging!</h2>
<p>Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates?  Here&#8217;s what I used today to do it:</p>
<pre><code>
# Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg

# Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU'RE DOING!)
find . -mindepth 3 -exec jhead -de "{}" \;

# Make Fresh EXIF tags
find . -mindepth 3 -exec jhead -mkexif "{}" \;

# Set the dates according to the Year and Month information in the filenames
find . -mindepth 3 | perl -ne '@a = split(/\//, $_); chomp($_); print `jhead -da$a[1]:$a[2]:01-2007:09:17 "$_"`, "\n"'
</code></pre>
<p>This worked wonderfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/09/18/setting-exif-dates-with-a-loop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using seq to zero-pad strings in a series</title>
		<link>http://www.ralree.com/2007/05/19/using-seq-to-zero-pad-strings-in-a-series/</link>
		<comments>http://www.ralree.com/2007/05/19/using-seq-to-zero-pad-strings-in-a-series/#comments</comments>
		<pubDate>Sat, 19 May 2007 08:06:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/using-seq-to-zero-pad-strings-in-a-series</guid>
		<description><![CDATA[I thought this was pretty cool: for i in `seq -f &#34;%03g&#34; 1 100`; do wget http://www.gozerog.com/images/Hawking_$i.jpg; done We were trying to do this the other night using bash, but to no avail since the square brackets only work for local file path expansion. I should have remembered seq. Also, this example shows how to 0-pad a series using seq and bash, noted by the *-f* option. Three cheers for seq!]]></description>
			<content:encoded><![CDATA[<p>I thought this was pretty cool:</p>
<div class="CodeRay">
<div class="code">
<pre><code>
for i in `seq -f &quot;%03g&quot; 1 100`; do wget http://www.gozerog.com/images/Hawking_$i.jpg; done
</code></pre>
</div>
</div>
<p>We were trying to do this the other night using bash, but to no avail since the square brackets only work for local file path expansion.  I should have remembered <code>seq</code>.  Also, this example shows how to 0-pad a series using seq and bash, noted by the <em>*-f</em>* option.  Three cheers for <code>seq</code>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/05/19/using-seq-to-zero-pad-strings-in-a-series/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

