<?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>BASH Cures Cancer &#187; video</title>
	<atom:link href="http://bashcurescancer.com/category/video/feed" rel="self" type="application/rss+xml" />
	<link>http://bashcurescancer.com</link>
	<description>Learn the UNIX/Linux command line</description>
	<lastBuildDate>Tue, 25 Oct 2011 18:09:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Keeping your SSH sessions alive with NOOP</title>
		<link>http://bashcurescancer.com/keeping-your-ssh-sessions-alive-with-noop.html</link>
		<comments>http://bashcurescancer.com/keeping-your-ssh-sessions-alive-with-noop.html#comments</comments>
		<pubDate>Wed, 12 Mar 2008 23:45:01 +0000</pubDate>
		<dc:creator>Brock Noland</dc:creator>
				<category><![CDATA[script]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://bashcurescancer.com/keeping-your-ssh-sessions-alive-with-noop.html</guid>
		<description><![CDATA[In the past, my SSH sessions died due to inactivity. In order to solve this, I used to: while true; do uptime; sleep 5;done Obviously, this eventually clears your terminal history. BASH to rescue! My noop script solves this problem. (Please see comments, there maybe a better solution, thanks David!) noop, standing for no operation, [...]]]></description>
			<content:encoded><![CDATA[<p>In the past, my SSH sessions died due to inactivity.  In order to solve this, I used to:</p>
<pre>while true; do uptime; sleep 5;done</pre>
<p>Obviously, this eventually clears your terminal history. BASH to rescue! My <a href="http://bashcurescancer.com/media/scripts/noop.txt">noop script</a> solves this problem. (Please see comments, there maybe a better solution, thanks David!) noop, standing for no operation, is a processor instruction and is common in protocols. You may find it interesting, that exploit code is filled with NOP&#8217;s. The operation increases your chances of exploiting <a href="http://en.wikipedia.org/wiki/Buffer_overflow#Nop_sled_technique">buffer overflows</a></p>
<p>The source:</p>
<pre>$ cat /usr/bin/noop
#!/bin/bash
backspace() {
        echo -e "\b\c"
}
cleanup() {
        backspace
        exit
}
trap "cleanup" 2
while :
do
        num=${RANDOM:0:1}
        printf $num
        sleep ".$num"
        backspace
done</pre>
<p>For the hell of it, I made a <a href="http://www.youtube.com/watch?v=BeBvp5gEyGU">video of noop in action</a>.</p>
<p>If your wondering how the script works, here is a quick explanation. The script defines two functions. backspace and cleanup. Backspace prints the special characters \b and \c.  Backslash b is a backspace, and backslash c, stops echo from printing a trailing newline:</p>
<pre>backspace() {
        echo -e "\b\c"
}</pre>
<p>The cleanup function prints a backspace and then exits.  The cleanup function is run by trap when it receives a SIGINT (2):</p>
<pre>cleanup() {
        backspace
        exit
}
trap "cleanup" 2</pre>
<p>The main body of the script, is an infinite loop which generates, a random number using the special variable $RANDOM. This random is assigned to the variable <em>num</em>, <a href="http://bashcurescancer.com/10-steps-to-beautiful-shell-scripts.html">utilizing only the first digit</a>. After printing that number, the script sleeps <em>num</em> tenths of seconds, and the backspace function is called:</p>
<pre>while :
do
        num=${RANDOM:0:1}
        printf $num
        sleep ".$num"
        backspace
done</pre>
]]></content:encoded>
			<wfw:commentRss>http://bashcurescancer.com/keeping-your-ssh-sessions-alive-with-noop.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.197 seconds -->

