<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/"/>

<title>Jeff Epler's blog</title>
<modified>2013-11-04T21:38:37Z</modified>
<tagline>Photos, electronics, cnc, and more</tagline>
<author><name>Jeff Epler</name><email>jepler@unpythonic.net</email></author>
<entry>
<title>report-if-fail, replace-if-success</title>
<issued>2013-11-04T21:38:37Z</issued>
<modified>2013-11-04T21:38:37Z</modified>
<id>https://gamma.unpythonic.net/01383601117</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01383601117"/>
<content type="text/html" mode="escaped">

I run a lot of scripts from cron, and only want to hear about them
when they fail.  That's precisely what this script does.  Just
insert it at the start of your cron command, e.g.,
&lt;pre&gt;
@hourly report-if-fail rsync-some-stuff
&lt;/pre&gt;
your script has to produce its output on stdout+stderr, and exit
with 0 for success and nonzero for any failure.

&lt;p&gt;Another thing I do is produce reports into static web pages, but
sometimes the reports fail e.g., due to transient network errors.
In these cases I want to keep the old version.  That's what
replace-if-success does: If the command succeeds then it replaces
its target file with the command's stdout.  Otherwise, it leaves the
target file untouched.  In any case, it returns the underlying
program's exit status, so you can also combine it with
report-if-fail. (report-if-fail will e-mail the stderr only in this
case)
&lt;pre&gt;
@hourly replace-if-success /var/www/stats.txt gather-some-statistics
&lt;/pre&gt;

&lt;p&gt;&lt;p&gt;&lt;b&gt;Files currently attached to this page:&lt;/b&gt;
&lt;table cellpadding=5 style=&quot;width:auto!important; clear:none!important&quot;&gt;&lt;col&gt;&lt;col style=&quot;text-align: right&quot;&gt;&lt;tr bgcolor=#eeeeee&gt;&lt;td&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01383601117/replace-if-success&quot;&gt;replace-if-success&lt;/a&gt;&lt;/td&gt;&lt;td&gt;116 bytes&lt;/td&gt;&lt;/tr&gt;&lt;tr bgcolor=#dddddd&gt;&lt;td&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01383601117/report-if-fail&quot;&gt;report-if-fail&lt;/a&gt;&lt;/td&gt;&lt;td&gt;285 bytes&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;

&lt;p&gt;In the author's view, these short scripts, report-if-fail and
replace-if-success, are too trivial to be subject to copyright.  In
the event that you disagree with this assessment, you may also
use these works under the terms of the &lt;a href=&quot;http://creativecommons.org/choose/zero/&quot;&gt;CC0&lt;/a&gt; license.
</content>
</entry>
<entry>
<title>Half-maximize script for Linux</title>
<issued>2012-02-29T15:42:38Z</issued>
<modified>2012-02-29T15:42:38Z</modified>
<id>https://gamma.unpythonic.net/01330530158</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01330530158"/>
<content type="text/html" mode="escaped">
A number of times, I've said that I like the Windows 7 feature that allows
a window to easily be half-maximized.  I got tired of waiting for it to be
added to my favorite window manager, so I wrote a script that uses
the program &lt;tt&gt;wmctrl&lt;/tt&gt; to half-maximize windows, then bound it
to key presses in my window manager.  Now, with a press of ctrl+alt+[QWER],
I can half-maximize a window into 4 locations on my dual-monitor setup.</content>
</entry>
</feed>
