<?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>tail -f /dev/null &#187; automation</title>
	<atom:link href="http://tfdn.radiofreeomaha.net/tag/automation/feed/" rel="self" type="application/rss+xml" />
	<link>http://tfdn.radiofreeomaha.net</link>
	<description>Tips, notes, HOWTOs</description>
	<lastBuildDate>Fri, 20 Aug 2010 04:13:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Simple Vim Macros</title>
		<link>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/</link>
		<comments>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 18:27:29 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=96</guid>
		<description><![CDATA[I found myself editing a configuration file (multiple actually) at work today and ran into an issue.  The config file looked similar to: Var_1=A Var_2=B Var_3=C ... Var_146=ABC Var_147=ABD As it happened I needed to remove one of the lines at position 23.  The program that reads/uses these config files has an issue if there [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I found myself editing a configuration file (multiple actually) at work today and ran into an issue.  The config file looked similar to:</p>
<pre class="brush: bash">
Var_1=A
Var_2=B
Var_3=C
...
Var_146=ABC
Var_147=ABD
</pre>
<p>As it happened I needed to remove one of the lines at position 23.  The program that reads/uses these config files has an issue if there is a break in the sequence.  So after removing the line with &#8220;Var_23&#8243; I needed to shift all of the numbers in following lines down by 1.  Here is how I accomplished that.</p>
<p>In vim I put my cursor on the 24 in the line that now follows the &#8220;Var_22&#8243; line and performed the following commands:</p>
<pre class="brush: bash">
qa
CTRL-X
j
q
125@a
</pre>
<p>Here is what happened broken down by line:</p>
<p>1: Here I am recording a macro (q) with the name or identifier of &#8216;a&#8217;.  Note you will probably see some indication in the last line that you are in &#8220;recording&#8221; mode.</p>
<p>2: CTRL-X decrements the number under the cursor.  Since I am on the 24 that decrements it to 23.</p>
<p>3:  I move down 1 line and now the cursor is on the 25 in the next line.</p>
<p>4: I quit recording the macro.  I know have a named (a) macro that includes the commands &#8220;decrement the number under the cursor and move down one row&#8221;.</p>
<p>5: I perform that named (a) macro 125 times.  Now realistically I only needed to do it 123 times.  It didn&#8217;t seem to matter that I used 125 but YMMV.  The first line after the last line I wanted to change was a blank line so I assume the macro quit when the CTRL-X failed.  You are probably better off using the exact number.</p>
<p>And there you have it.  I successfully renumbered all of the variables below the line I deleted to be in sequence.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=9ec0d12e-548c-44ca-8cc8-0f9543ba456a" alt="" /><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add A Comma To The End Of A Line</title>
		<link>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/</link>
		<comments>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 16:59:49 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[substitute]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=66</guid>
		<description><![CDATA[I work with long lists and WinSQL a lot.  I always find myself wishing these long lists had commas at the end for pasting into a SQL where clause using &#8220;IN&#8221; for the list.  This can be accomplished in one of two ways. From the command line: sed &#34;s/$/,/g&#34; &#60;FILENAME&#62; I usually pipe the output [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I work with long lists and WinSQL a lot.  I always find myself wishing these long lists had commas at the end for pasting into a SQL where clause using &#8220;IN&#8221; for the list.  This can be accomplished in one of two ways.</p>
<p>From the command line:</p>
<pre class="brush: bash">sed &quot;s/$/,/g&quot; &lt;FILENAME&gt;</pre>
<p>I usually pipe the output there to a new file.</p>
<p>In vi (from command mode):</p>
<pre class="brush: bash">:%s/$/,/g</pre>
<p>The &#8220;%&#8221; says to perfom the substitution on the whole file.  In both cases we are doing a substitution of &#8220;$&#8221; (the end of the line) with a &#8220;,&#8221;.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pause Torrent Downloads When Screensaver Is Inactive</title>
		<link>http://tfdn.radiofreeomaha.net/2008/12/pause-torrent-downloads-when-screensaver-is-inactive/</link>
		<comments>http://tfdn.radiofreeomaha.net/2008/12/pause-torrent-downloads-when-screensaver-is-inactive/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 05:39:41 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[bittorrent]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=10</guid>
		<description><![CDATA[If you use Transmission this little python script will start all of your downloads when your screensaver kicks on and pause them when it turns off, i.e. you are at your terminal. #!/usr/bin/env python import dbus, urllib from dbus.mainloop.glib import DBusGMainLoop START_TORRENTS = &#34;http://localhost:9091/transmission/rpc?method=torrent-start&#34; STOP_TORRENTS = &#34;http://localhost:9091/transmission/rpc?method=torrent-stop&#34; DBusGMainLoop(set_as_default=True) sess=dbus.SessionBus() def sig(screensaverActive): if screensaverActive: data = [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://www.transmissionbt.com/" target="_blank">Transmission</a> this little python script will start all of your downloads when your screensaver kicks on and pause them when it turns off, i.e. you are at your terminal.</p>
<pre>
<pre class="brush: python">#!/usr/bin/env python
import dbus, urllib
from dbus.mainloop.glib import DBusGMainLoop

START_TORRENTS = &quot;http://localhost:9091/transmission/rpc?method=torrent-start&quot;
STOP_TORRENTS = &quot;http://localhost:9091/transmission/rpc?method=torrent-stop&quot;

DBusGMainLoop(set_as_default=True)
sess=dbus.SessionBus()
def sig(screensaverActive):
  if screensaverActive:
    data = urllib.urlopen(START_TORRENTS).read()
  else:
    data = urllib.urlopen(STOP_TORRENTS).read()

sess.add_signal_receiver(sig, &#039;ActiveChanged&#039;,&#039;org.gnome.ScreenSaver&#039;)
import gobject
loop = gobject.MainLoop()
loop.run()</pre>
<p>via <span style="color: #ff0000;">I can&#8217;t find it at the moment but I will update once I get the link.  <img src='http://tfdn.radiofreeomaha.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </span></p>
<p>UPDATE:</p>
<p>I found my source <a href="http://www.kryogenix.org/days/2008/11/15/pause-torrents-while-im-using-the-computer" target="_blank">here</a>.  The comments also include a patch for throttling the app rather than outright pausing everything.</p>
<p><strong><span style="text-decoration: underline;"><span style="color: #ff0000;">SECURITY</span></span></strong>: I should point out, as mentioned in <a href="http://www.kryogenix.org/days/2008/11/15/pause-torrents-while-im-using-the-computer#comment-122886" target="_blank">this</a> comment, the RPC for Transmission will allow a nefarious person to control your application with a web page that includes elements like:</p>
<pre>
<pre class="brush: html">&lt;img src=&quot;http://localhost:9091/transmission/rpc?method=torrent-stop&quot;&gt;</pre>
<p>It is assumed that most (all?) other RPC calls for the web interface of Transmission could be called the same way.  This is a fairly large security hole and I would suggest using a password on the Transmission web interface if you enable it.  Though if you do that would render this tip pretty much useless.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2008/12/pause-torrent-downloads-when-screensaver-is-inactive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

