<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; Shell</title>
	<atom:link href="http://www.g-loaded.eu/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>PHP Interactive Interpreter</title>
		<link>http://www.g-loaded.eu/2010/04/13/php-interactive-interpreter/</link>
		<comments>http://www.g-loaded.eu/2010/04/13/php-interactive-interpreter/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 13:16:42 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=1157</guid>
		<description><![CDATA[The PHP interpreter supports running it in interactive mode by using the --interactive (short equivalent: -a) command-line switch. Running an interactive PHP shell can be useful when you need to quickly try code snippets. But, for this mode to be fully functional, PHP has to be compiled with readline support. Unfortunately, on CentOS PHP has [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://php.net">PHP</a> interpreter supports running it in interactive mode by using the <code>--interactive</code> (short equivalent: <code>-a</code>) command-line switch. Running an interactive PHP shell can be useful when you need to quickly try code snippets. But, for this mode to be fully functional, PHP has to be compiled with <strong>readline</strong> support. Unfortunately, on <strong>CentOS</strong> PHP has not been compiled this way.<br />
<span id="more-1157"></span><br />
You can check the PHP compile-time configuration switches, by invoking the following command:</p>
<pre class="console">
php --info | grep -i 'configure command'
</pre>
<p>While searching for a solution about this, I ran across an interesting project, <a href="http://david.acz.org/phpa/">phpa</a>. From the developer:</p>
<blockquote><p>
phpa is an interactive command line shell for PHP.</p>
<p>It is a replacement for the interactive mode of the PHP interpreter (php -a), hence the name.</p>
<p>This software is public domain.
</p></blockquote>
<p>Before using it, make sure <strong>php-readline</strong> is installed:</p>
<pre class="console">
yum install php-readline
</pre>
<p>I downloaded <strong>phpa</strong> and set the <strong>executable</strong> bit as shown below:</p>
<pre class="console">
wget -O - http://david.acz.org/phpa/phpa.txt > ~/bin/phpa
chmod +x ~/bin/phpa
</pre>
<p>I also had to fix the bad <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a>:</p>
<pre class="console">
sed -i 's#/usr/local/bin/php#/usr/bin/php#' ~/bin/phpa
</pre>
<p>Finally, an interactive PHP shell! Now running code snippets from the <a href="http://php.net/manual/en/index.php">PHP manual</a> is fun:</p>
<pre class="console">
[rocky@arena ~]$ phpa
PHP 5.1.6 (cli) (Jan 13 2010 17:05:38) [Linux]
>>> $arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42));
>>>
>>> echo $arr["somearray"][6];    // 5
5
>>> echo $arr["somearray"][13];   // 9
9
>>> echo $arr["somearray"]["a"];  // 42
42
>>>
</pre>
<p>Enjoy your new PHP interactive interpreter!</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2010/04/13/php-interactive-interpreter/">PHP Interactive Interpreter</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
  <p>No related articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2010/04/13/php-interactive-interpreter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>How to extract RPM or DEB packages</title>
		<link>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/</link>
		<comments>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 00:30:32 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[DEB]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Packaging]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Shell]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/</guid>
		<description><![CDATA[RPM and DEB packages are both containers for other files. An RPM is some sort of cpio archive. On the other hand, a DEB file is a pure ar archive. So, it should be possible to unpack their contents using standard archiving tools, regardless of your distribution&#8217;s package format. Under normal conditions, you should use [...]]]></description>
			<content:encoded><![CDATA[<p>RPM and DEB packages are both containers for other files. An RPM is some sort of <strong>cpio</strong> archive. On the other hand, a DEB file is a pure <strong>ar</strong> archive. So, it should be possible to unpack their contents using standard archiving tools, regardless of your distribution&#8217;s package format. Under normal conditions, you should use your distribution&#8217;s standard package manager, <strong>rpm</strong> or <strong>dpkg</strong> and their frontends, to manage those files. But, if you need to be more generic, here is how to do it.<br />
<span id="more-482"></span></p>
<h4>RPM</h4>
<p>For RPMs you need two command line utilities, <strong>rpm2cpio</strong> and <strong>cpio</strong>. Extracting the contents of the RPM package is a <em>one step</em> process:</p>
<pre class="console">rpm2cpio mypackage.rpm | cpio -vid</pre>
<p>If you just need to list the contents of the package without extracting them, use the following:</p>
<pre class="console">rpm2cpio mypackage.rpm | cpio -vt</pre>
<p>The <strong>-v</strong> option is used in order to get verbose output to the stdout. If you don&#8217;t need it, you can safely omit this switch. For more information about the <code>cpio</code> options, please refer to the <code>cpio(1)</code> manual page.</p>
<h4>DEB</h4>
<p>DEB files are <em>ar archives</em>, which contain three files:</p>
<ul>
<li>debian-binary</li>
<li>control.tar.gz</li>
<li>data.tar.gz</li>
</ul>
<p>As you might have already guessed, the needed archived files exist in <code>data.tar.gz</code>. It is also obvious that unpacking this file is a <em>two-step</em> process.</p>
<p>First, extract the aforementioned three files from the DEB file (<strong>ar</strong> archive):</p>
<pre class="console">ar vx mypackage.deb</pre>
<p>Then extract the contents of <code>data.tar.gz</code> using <strong>tar</strong>:</p>
<pre class="console">tar -xzvf data.tar.gz</pre>
<p>Or, if you just need to get a <em>listing</em> of the files:</p>
<pre class="console">tar -tzvf data.tar.gz</pre>
<p>Again the <strong>-v</strong> option in both <strong>ar</strong> and <strong>tar</strong> is used in order to get verbose output. It is safe not to use it. For more information, read the man pages: <code>tar(1)</code> and <code>ar(1)</code>.</p>
<p><strike>If anyone knows a <em>one step process</em> to extract the contents of the <code>data.tar.gz</code>, I&#8217;d be very interested in it!</strike></p>
<p><strong>Update</strong></p>
<p>As Jon <a href="http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/comment-page-1/#comment-11671">suggested</a> in the comment area, the contents of data.tar.gz can be extracted from the DEB package in a one step process as shown below:</p>
<pre class="console">
ar p mypackage.deb data.tar.gz | tar zx
</pre>
<p>That will do it.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/">How to extract RPM or DEB packages</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/12/01/choosing-a-format-for-data-backups-tar-vs-cpio/" rel="bookmark">Choosing a format for data backups &#8211; tar vs cpio</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/05/how-to-build-rpm-packages-on-fedora/" rel="bookmark">How To Build RPM Packages on Fedora</a></li>
<li><a href="http://www.g-loaded.eu/2007/12/01/veritar-verify-checksums-of-files-within-a-tar-archive/" rel="bookmark">VeriTAR &#8211; Verify checksums of files within a TAR archive</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/07/verify-a-burned-cddvd-image-on-linux/" rel="bookmark">Verify a burned CD/DVD image on Linux</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/08/linux-tips-pack-i/" rel="bookmark">Linux Tips &#8211; Pack I</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Upgraded to WordPress 2.3.1</title>
		<link>http://www.g-loaded.eu/2007/11/04/upgraded-to-wordpress-231/</link>
		<comments>http://www.g-loaded.eu/2007/11/04/upgraded-to-wordpress-231/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 22:13:33 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/11/04/upgraded-to-wordpress-231/</guid>
		<description><![CDATA[I finally made the decision to upgrade WordPress to the latest 2.3.1 version. I skipped the initial v2.3 release as I had read that there was a lengthy list of bugs about that release, which eventually have been fixed in 2.3.1. Everything seems to run smoothly. I intend to spend some time browsing around my [...]]]></description>
			<content:encoded><![CDATA[<p>I finally made the decision to upgrade WordPress to the latest 2.3.1 version. I skipped the initial v2.3 release as I had read that there was a lengthy list of bugs about that release, which eventually have been fixed in 2.3.1. Everything seems to run smoothly. I intend to spend some time browsing around my website to test it and by the way fix a few things here and there.</p>
<p>A while ago I had written a script that would automate the WordPress upgrade process. Such a program could have been a simple shell script, just a few lines of code. However, I decided to write a more flexible script in Python instead, which can keep backups, perform a thorough upgrade of the website&#8217;s platform, keep the files I need to keep etc. A script that takes good care of everything while upgrading is also a good idea because it minimizes downtime while performing upgrades. Today was the first time to test it. After the upgrade, everything seems to be where it should. The script is in pre-alpha state and despite the fact that I used it on my website, it is not ready for release yet. Below is the output of the upgrade on G-Loaded:<br />
<span id="more-455"></span></p>
<pre class="codesnp">
# python wpupgrade.py 2.3.1
info: ++ Performings Tests. Please wait...
info: Initial configuration checks - OK
info: Retrieval of WordPress database settings from wp-config.php - OK
info: Checking existence of mysqldump - OK
info: ++ Starting data backup. Please wait...
info: Database backup - OK
info: Filesystem backup - OK
info: Data backup Complete
info: ++ Downloading wordpress archive. Please wait...
info: Download and Verification Complete
info: ++ Removing old WordPress files and directories. Listing follows:
info: Removed DIR: wp-admin
info: Removed DIR: wp-includes - PRESERVED wp-includes/languages
warning: --> DIR wp-content/cache CANNOT BE REMOVED - NOT CRITICAL - REMOVE MANUALLY IF POSSIBLE
info: Removed FILE: wp-commentsrss2.php
info: Removed FILE: wp-rss.php
info: Removed FILE: wp-rdf.php
info: Removed FILE: wp-login.php
info: Removed FILE: wp-app.php
info: Removed FILE: wp-settings.php
info: Removed FILE: wp-comments-post.php
info: Removed FILE: wp-mail.php
info: Removed FILE: wp-rss2.php
info: Removed FILE: wp-pass.php
info: Removed FILE: wp-blog-header.php
info: Removed FILE: wp-register.php
info: Removed FILE: wp-feed.php
info: Removed FILE: wp-trackback.php
info: Removed FILE: wp-cron.php
info: Removed FILE: wp-links-opml.php
info: Removed FILE: wp-config-sample.php
info: Removed FILE: wp-atom.php
info: Removed FILE: index.php
info: Removed FILE: xmlrpc.php
info: Removed FILE: readme.html
info: Removed FILE: license.txt
info: WordPress files removal complete
info: ++ WordPress Upgrade
info: Writing new files. Please wait...
info: File Upgrade Complete
info: ++ Starting Cleanup
info: Nothing - TODO
info: Finish Upgrade by visiting: http://www.yoursite.org/wp-admin/upgrade.php
</pre>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/11/04/upgraded-to-wordpress-231/">Upgraded to WordPress 2.3.1</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2008/12/17/upgraded-to-wordpress-coltrane/" rel="bookmark">Upgraded to WordPress Coltrane</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/01/upgraded-to-wordpress-2/" rel="bookmark">Upgraded to WordPress 2</a></li>
<li><a href="http://www.g-loaded.eu/2007/03/03/highly-exploitable-code-planted-into-wordpress-211/" rel="bookmark">Highly Exploitable Code Planted into WordPress 2.1.1</a></li>
<li><a href="http://www.g-loaded.eu/2007/02/09/server-upgraded-to-fedora-6/" rel="bookmark">Server upgraded to Fedora 6</a></li>
<li><a href="http://www.g-loaded.eu/2008/03/31/wordpress-25-plugin-compatibility/" rel="bookmark">WordPress 2.5 &#8211; Plugin Compatibility</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/11/04/upgraded-to-wordpress-231/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Use wget or curl to download from RapidShare Premium</title>
		<link>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/</link>
		<comments>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 08:55:17 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Snippet]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/</guid>
		<description><![CDATA[This article describes how to use the command line download managers wget and curl in order to download files from your Rapidshare Premium account.]]></description>
			<content:encoded><![CDATA[<p>The last days I needed to download a bunch of medical videos which have been uploaded to RapidShare by many other people. Although RapidShare (and all the other 1-click file-hosting services) is very convenient, it has some strict rules for free accounts, for example a guest has to wait for 120 seconds per 1 MB of downloaded data and &#8211; to make it worse &#8211; no download managers are allowed. Since &#8220;waiting&#8221; is not a game I like and since I intended to use either <a href="http://www.gnu.org/software/wget/">wget</a> or <a href="http://curl.haxx.se/">curl</a> to download the files, I decided to sign up for a <a href="http://www.rapidshare.com/">RapidShare</a> Premium account and then figure out how to use the aforementioned tools. Fortunately, registered users are permitted to use download managers and, as you will read in the following article, the Linux command line downloaders work flawlessly with a Premier account.<br />
<span id="more-443"></span></p>
<h4>Theory</h4>
<p>Rapidshare uses cookie-based authentication. This means that every time you log into the service, a cookie containing information which identifies you as a registered user is stored in your browser&#8217;s cookie cache. Both <code>wget</code> and <code>curl</code> support saving and loading cookies, so before using them to download any files, you should save such a cookie. Having done this, then the only required action in order download from RapidShare is to load the cookie, so that wget or curl can use it to authenticate you on the RapidShare server. This is pretty much the same you would do with a graphical download manager. The difference now is that you do it on the command line.</p>
<p>Below you will find examples about how to perform these actions using both wget and curl.</p>
<p><strong>IMPORTANT</strong>: Please note that in order to use these command-line utilities or any other download managers with RapidShare, you will have to check the <strong>Direct Downloads option</strong> in your account&#8217;s <strong>options page</strong>.</p>
<h4>Save your RapidShare Premium Account Cookie</h4>
<p>Saving your RapidShare cookie is a procedure that needs to be done <strong>once</strong>.</p>
<p>The login page is located at:</p>
<pre class="codesnp">https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi</pre>
<p>The login form requires two fields: <strong>login</strong> and <strong>password</strong>. These are pretty self-explanatory.</p>
<p>In the following examples, the RapidShare username is shown as <strong>USERNAME</strong> and the password as <strong>PASSWORD</strong>.</p>
<h5>Using wget</h5>
<p>In order to save your cookie using wget, run the following:</p>
<pre class="console">
wget \
    --save-cookies ~/.cookies/rapidshare \
    --post-data "login=USERNAME&#038;password=PASSWORD" \
    -O - \
    https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi \
    > /dev/null
</pre>
<p><strong>&#8211;save-cookies</strong> : Saves the cookie to a file called <code>rapidshare</code> under the <code>~/.cookies</code> directory (let&#8217;s assume that you store your cookies there)<br />
<strong>&#8211;post-data</strong> : is the POST payload of the request. In other words it contains the data you would enter in the login form.<br />
<strong>-O -</strong> : downloads the HTML data to the standard output. Since the above command is run only in order to obtain the cookie, this option prints the HTML data to stdout (Standard Output) and then discards it by redirecting stdout to <code>/dev/null</code>. If you don&#8217;t do this, wget will save the HTML data in a file called <code>premiumzone.cgi</code> in the current directory. This is just the Rapidshare HTML page, which is absolutely not needed.</p>
<h5>Using curl</h5>
<p>In order to save your cookie using curl, run the following:</p>
<pre class="console">
curl \
    --cookie-jar ~/.cookies/rapidshare \
    --data "login=USERNAME&#038;password=PASSWORD" \
    https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi \
    > /dev/null
</pre>
<p><strong>&#8211;cookie-jar</strong> : Saves the cookie to a file called <code>rapidshare</code> under the <code>~/.cookies</code> directory (it has been assumed previously that cookies are stored there)<br />
<strong>&#8211;data</strong> : contains the data you would enter in the login form.<br />
Curl prints the downloaded page data to stdout by default. This is discarded by sending it to <code>/dev/null</code>.</p>
<h4>Download files using your RapidShare Premium Account Cookie</h4>
<p>Having saved your cookie, downloading files from RapidShare is as easy as telling wget/curl to load the cookie everytime you use them to download a file.</p>
<h5>Downloading with wget</h5>
<p>In order to download a file with wget, run the following:</p>
<pre class="console">
wget -c --load-cookies ~/.cookies/rapidshare &lt;URL&gt;
</pre>
<p><strong>-c </strong>: this is used in order to resume downloading of the file if it already exists in the current directory and is incomplete.<br />
<strong>&#8211;load-cookies</strong> : loads your cookie.</p>
<h5>Downloading with curl</h5>
<p>In the same manner, in order to download a file with curl, run the following:</p>
<pre class="console">
curl -L -O --cookie ~/.cookies/rapidshare &lt;URL&gt;
</pre>
<p><strong>-L</strong> : Follows all redirections until the final destination page is found. This switch is almost always required as curl won&#8217;t follow redirects by default (read about how to check the server <a href="http://www.g-loaded.eu/2006/10/06/check-server-http-headers-with-curl/">http headers</a> with curl).<br />
<strong>-O</strong> : By using this switch you instruct curl to save the downloaded data to a file in the current directory. The filename of the remote file is used. This switch is also required or else curl will print the data to stdout, which is something you won&#8217;t probably like.<br />
<strong>&#8211;cookie</strong> : loads your Rapidshare account&#8217;s cookie.</p>
<h4>Setting up a Download Server</h4>
<p>Although most users would be satisfied with the above, I wouldn&#8217;t be surprised if you would want to go a bit further and try to setup a little service for your downloading pleasure. Here is a very primitive implementation of such a service. All you will need is standard command line tools.</p>
<p>This primitive server consists of the following:</p>
<ol>
<li>A <a href="http://en.wikipedia.org/wiki/Named_pipe">named pipe</a>, called &#8220;<strong>dlbasket</strong>&#8220;. You will feed the server with URLs through this pipe. Another approach would be to use a listening TCP socket with <a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/">NetCat</a>.</li>
<li>A script, which, among others, contains the main server loop. This loop reads one URL at a time from dlbasket and starts a wget/curl process in order to download the file. If dlbasket is empty, the server should just stay there waiting.</li>
</ol>
<p>So, in short, the service would be the following:</p>
<pre class="codesnp">
cat &lt;&gt; dlbasket | ( while ... done )
</pre>
<p>All credit for the &#8220;<strong>cat &lt;&gt; dlbasket |</strong>&#8221; magic goes to <strong><em>Zart</em></strong>, who kindly helped me out at the #fedora IRC channel.</p>
<p>So, let&#8217;s create that service. The following assume that a user named &#8220;<strong>downloader</strong>&#8221; exists in the system and the home directory is <code>/var/lib/downloader/</code>. Of course you can set this up as you like, but make sure you adjust the following commands and the script&#8217;s configuration options accordingly.</p>
<p>First, create the named pipe:</p>
<pre class="console">
mkfifo -m 0700 /var/lib/downloader/dlbasket
</pre>
<p>If it does not exist, create a <code>bin</code> directory in the user&#8217;s home:</p>
<pre class="console">
mkdir -p /var/lib/downloader/bin
</pre>
<p>Also, create a directory where the downloaded files will be saved:</p>
<pre class="console">
mkdir -p /var/lib/downloader/downloads
</pre>
<p>The following is a quick and dirty script I wrote which actually implements the service. Save it as <strong>rsgetd.sh</strong> inside the user&#8217;s <code>bin</code> directory:</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /usr/bin/env bash  </span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  rsgetd.sh - Download Service</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  Version 0.3</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  Copyright (C) 2007 George Notaras (http://www.g-loaded.eu/)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  This program is free software; you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#  it under the terms of the GNU General Public License version 2 as</span>
<span style="color: #666666; font-style: italic;">#  published by the Free Software Foundation.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#  GNU General Public License for more details.</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Special thanks to 'Zart' from the #fedora channel on FreeNode</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># v0.3 - Oct 31 2009:</span>
<span style="color: #666666; font-style: italic;"># - corrected error: &quot;./bin/rsgetd.sh: line 37: [: argument expected&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># CONFIG START </span>
<span style="color: #007800;">HOMEDIR</span>=<span style="color: #ff0000;">&quot;/var/lib/downloader&quot;</span>
<span style="color: #007800;">DLBASKET</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/dlbasket&quot;</span>
<span style="color: #007800;">DLDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/downloads/&quot;</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/.downloads_log&quot;</span>
<span style="color: #007800;">CACHEFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/.downloads_cache&quot;</span>
<span style="color: #007800;">LIMIT</span>=<span style="color: #ff0000;">&quot;25k&quot;</span>
<span style="color: #007800;">WGETBIN</span>=<span style="color: #ff0000;">&quot;/usr/bin/wget&quot;</span>
<span style="color: #666666; font-style: italic;"># Rapidshare Login Cookie  </span>
<span style="color: #007800;">RSCOOKIE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/cookies/.rapidshare&quot;</span>
<span style="color: #666666; font-style: italic;"># CONFIG END</span>
&nbsp;
<span style="color: #007800;">DATETIME</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`date '+%Y-%m-%d %H:%M:%S'`</span>&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$DLBASKET</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> url ; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #666666; font-style: italic;"># First, check the cache if the file has been already downloaded</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CACHEFILE</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(grep -i $(basename $url)</span> <span style="color: #007800;">$CACHEFILE</span>)&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                       <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> File exists in cache. Already downloaded - Skipping: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> Starting with rate <span style="color: #007800;">$LIMIT</span>/s: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">expr</span> match <span style="color: #ff0000;">&quot;<span style="color: #007800;">$url</span>&quot;</span> <span style="color: #ff0000;">'[rapidshare.com]'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                                <span style="color: #666666; font-style: italic;"># If it is a Rapidshare.com link, load the RS cookie </span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;RAPIDSHARE LINK&quot;</span>
                                <span style="color: #007800;">$WGETBIN</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--limit-rate</span>=<span style="color: #007800;">$LIMIT</span> <span style="color: #660033;">--directory-prefix</span>=<span style="color: #007800;">$DLDIR</span> <span style="color: #660033;">--load-cookies</span> <span style="color: #007800;">$RSCOOKIE</span> <span style="color: #007800;">$url</span>
                        <span style="color: #000000; font-weight: bold;">else</span>
                                <span style="color: #007800;">$WGETBIN</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--limit-rate</span>=<span style="color: #007800;">$LIMIT</span> <span style="color: #660033;">--directory-prefix</span>=<span style="color: #007800;">$DLDIR</span> <span style="color: #007800;">$url</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> Finished: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$url</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$CACHEFILE</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>
<p>As you might have already noticed, two extra files are created inside the home directory: <code>.downloads_cache</code> and <code>.downloads_log</code>. The first contains a list of all the urls that have been downloaded. Each new download is checked against this list, so that the particular URL is not processed if the file has already been downloaded. The latter file is a usual logfile stating the start and end times of each download. Feel free to adjust the script to your needs.</p>
<p>Here is some info about how you should start the service:</p>
<p><strong>-1-</strong> You can simply start the script as a background process and then feed URLs to it. For example:</p>
<pre class="console">
rsgetd.sh &#038;
echo "&lt;URL&gt;" &gt; /var/lib/downloader/dlbasket
</pre>
<p><strong>-2-</strong> Use <a href="http://www.gnu.org/software/screen/">screen</a> in order to run the script in the background but still be able to see its output by connecting to a screen session. Although this is not a screen howto, here is an example:</p>
<p>Create a new screen session and attach to it:</p>
<pre class="console">
screen -S rs_downloads
</pre>
<p>While being in the session, run rsgetd.sh</p>
<pre class="console">
rsgetd.sh
</pre>
<p>From another terminal feed the download basket (dlbasket) with urls:</p>
<pre class="console">
echo "&lt;URL&gt;" &gt; /var/lib/downloader/dlbasket
cat url_list.txt &gt; /var/lib/downloader/dlbasket
</pre>
<p>Watch the files in the screen window as they are being downloaded.</p>
<p>Detach from the screen session by hitting the following:</p>
<pre class="codesnp">
Ctrl-a   d
</pre>
<p>Re-attach to the session by running:</p>
<pre class="console">
screen -r
</pre>
<p>Note that you do not need to be attached to the screen session in order to add URLs.</p>
<h5>Feeding the basket with URLs remotely</h5>
<p>Assuming that a SSH server is running on the machine that runs rsgetd.sh, you can feed URLs to it by running the following from a remote machine:</p>
<pre class="console">
ssh downloader@server.example.org cat \&gt; /var/lib/downloader/dlbasket
</pre>
<p>Note that the <strong>&gt;</strong> needs to be escaped so that it is considered as part of the command that will be executed on the remote server.</p>
<p>Now, feel free to <strong>add</strong> as many <strong>URLs</strong> as you like. After you hit the <strong>[Enter]</strong> key the url will be added to the download queue. When you are finished, just press <strong>Ctrl-D</strong> to end the URL submission.</p>
<h4>Conclusion</h4>
<p>This article provides all the information you need in order to use wget or curl to download files from your RapidShare Premium account. Also, information on how to set up a service that will assist you in order to commence downloads on your home server from a remote location has been covered.</p>
<p>The same information applies in all cases that wget and curl need to be used with websites that use cookie-based authentication.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/">Use wget or curl to download from RapidShare Premium</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2010/10/04/rsapiget-download-rapidshare-api/" rel="bookmark">rsapiget downloads files using the new Rapidshare API</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/06/check-server-http-headers-with-curl/" rel="bookmark">Check Server HTTP Headers with CURL</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/mass-download/" rel="bookmark">Mass download</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/" rel="bookmark">Partition images with Partimage and Partimaged</a></li>
<li><a href="http://www.g-loaded.eu/2010/03/28/script-apache-error-report/" rel="bookmark">Script for Apache Error Report</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>File and Directory diff in color in Midnight Commander</title>
		<link>http://www.g-loaded.eu/2007/08/06/file-and-directory-diff-in-color-in-midnight-commander/</link>
		<comments>http://www.g-loaded.eu/2007/08/06/file-and-directory-diff-in-color-in-midnight-commander/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 15:51:07 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/08/06/file-and-directory-diff-in-color-in-midnight-commander/</guid>
		<description><![CDATA[Midnight Commander (MC) is a lean, but powerful, two-panel file manager that, admittedly, promotes productivity while working from a console. Among other features, it implements a user menu with pre-defined actions that can be performed on the selected files or directories. This menu can be further customized by the user on a directory-, user- or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ibiblio.org/mc/">Midnight Commander</a> (MC) is a lean, but powerful, two-panel file manager that, admittedly, promotes productivity while working from a console. Among other features, it implements a <strong>user menu</strong> with pre-defined actions that can be performed on the selected files or directories. This menu can be further customized by the user on a directory-, user- or system-basis. While searching for ready-made actions for <abbr title="Midnight Commander">MC</abbr>&#8216;s user menu, I came across an excellent set, which adds the ability to display the differences (diff output) between two versions of a file or directory in color.<br />
<span id="more-435"></span></p>
<h4>Add the necessary code</h4>
<p>The code that needs to be added to the user menu is the following:</p>
<pre class="codesnp">
+ t r &#038; ! t t
d       Diff against file of same name in other directory
        if [ "%d" = "%D" ]; then
          echo "The two directores must be different"
          exit 1
        fi
        if [ -f %D/%f ]; then        # if two of them, then
          diff -up %f %D/%f | sed -e 's/\(^-.*\)/\x1b[1;31m\1\x1b[0m/g' \
                                  -e 's/\(^\+.*\)/\x1b[1;32m\1\x1b[0m/g' \
                                  -e 's/\(^@.*\)/\x1b[36m\1\x1b[0m/g' | less -R
        else
          echo %f: No copy in %D/%f
        fi
D       Diff current directory against other directory
        if [ "%d" = "%D" ]; then
          echo "The two directores must be different"
          exit 1
        fi
        diff -up %d %D | sed -e 's/\(^-.*\)/\x1b[1;31m\1\x1b[0m/g' \
                             -e 's/\(^\+.*\)/\x1b[1;32m\1\x1b[0m/g' \
                             -e 's/\(^@.*\)/\x1b[36m\1\x1b[0m/g' | less -R
        fi
</pre>
<p>The code snippet is a contribution by <cite>James Ogley</cite> to this <a href="http://en.opensuse.org/Midnight_Commander/Tips">OpenSUSE wiki page</a> about Midnight Commander and is released under the <a href="http://www.gnu.org/licenses/fdl.txt">GFDL 1.2 license</a>.</p>
<p>Here are the instructions on how to add this code to the user menu:</p>
<ol>
<li>Having launched Midnight Commander, press <strong>F9</strong></li>
<li>Go to the <strong>Command menu</strong> and hit the <strong>Edit menu file</strong></li>
<li>MC lets you customize the user menu for the current directory [<code>Local</code>], current user [<code>Home</code>] or make the modification system-wide. You will need to be <em>root</em> to change the latter. Most probably the <strong>Home</strong> choice is what you need.</li>
<li>You can now paste the code block between two other user-defined commands.</li>
</ol>
<h4>How to use these actions</h4>
<p>In order to show the differences between two versions of the same file, browse to the directories that contain each version, so that the directory in <em>panel A</em> contains the <em>A version</em> of <code>some.file</code> and the directory in <em>panel B</em> contains the <em>B version</em> of <code>some.file</code>. Then press <strong>F2</strong> and lowercase <strong>d</strong>.</p>
<p>In order to show the differences between the contents of the directories in the two panels, just press <strong>F2</strong> and then uppercase <strong>D</strong>.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/08/06/file-and-directory-diff-in-color-in-midnight-commander/">File and Directory diff in color in Midnight Commander</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/09/10/spec-file-directory/" rel="bookmark">SPEC File Directory</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/06/meld/" rel="bookmark">Meld&#8230;</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/09/making-a-directory-writable-by-the-webserver/" rel="bookmark">Making a directory writable by the webserver</a></li>
<li><a href="http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/" rel="bookmark">Use wget or curl to download from RapidShare Premium</a></li>
<li><a href="http://www.g-loaded.eu/2007/07/28/send-a-text-file-as-sms-with-a-sony-ericsson-mobile/" rel="bookmark">Send a text file as SMS with a Sony-Ericsson mobile</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/08/06/file-and-directory-diff-in-color-in-midnight-commander/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Watch Videos in ASCII Art</title>
		<link>http://www.g-loaded.eu/2007/07/01/watch-videos-in-ascii-art/</link>
		<comments>http://www.g-loaded.eu/2007/07/01/watch-videos-in-ascii-art/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 22:09:08 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/07/01/watch-videos-in-ascii-art/</guid>
		<description><![CDATA[This is an interesting article by O&#8217;Reilly Hacks, which provides tips on how to watch a video stream in ASCII art. From the article: Good ASCII art can take time and talent to look just right, but you can skip through that effort with AAlib, a library devoted to converting any image into an ASCII [...]]]></description>
			<content:encoded><![CDATA[<p>This is an interesting article by O&#8217;Reilly Hacks, which provides tips on how to watch a video stream in <a href="http://en.wikipedia.org/wiki/ASCII_art">ASCII art</a>. From the article:</p>
<blockquote><p>
Good ASCII art can take time and talent to look just right, but you can skip through that effort with AAlib, a library devoted to converting any image into an ASCII art equivalent. Since a movie is basically a system of moving images, MPlayer has added support for AAlib as a video output option. This means that each frame in the movie is converted to an ASCII equivalent and displayed on the screen.</p></blockquote>
<p>Software that is used to accomplish the task includes <a href="http://www.mplayerhq.hu/">MPlayer</a> multimedia player built with support for the <a href="http://aa-project.sourceforge.net/aalib/">ASCII art library</a> (<code>aalib</code>) and the <a href="http://libcaca.zoy.org/">color ASCII art library</a> (<code>libcaca</code>).</p>
<p><a href="http://www.oreilly.com/pub/h/4441">Read the full article here</a></p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/07/01/watch-videos-in-ascii-art/">Watch Videos in ASCII Art</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/10/05/training-videos/" rel="bookmark">Training Videos</a></li>
<li><a href="http://www.g-loaded.eu/2007/02/24/creative-commons-v30-licenses-launched/" rel="bookmark">Creative Commons v3.0 Licenses Launched</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/30/50-monitor-display/" rel="bookmark">50-Monitor Display</a></li>
<li><a href="http://www.g-loaded.eu/2006/05/02/tv-grabbing-on-a-pentium-3/" rel="bookmark">TV Grabbing On A Pentium 3</a></li>
<li><a href="http://www.g-loaded.eu/2007/03/15/screenshot-of-a-menu-under-gnome-round-2/" rel="bookmark">Screenshot of a menu under GNOME: ROUND 2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/07/01/watch-videos-in-ascii-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>How to create a Windows bootable CD with mkisofs</title>
		<link>http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/</link>
		<comments>http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 13:19:08 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/</guid>
		<description><![CDATA[Generally, the only reason for which you may need to create a bootable Windows CD is when you have updated the operating system installation files with the latest Service Pack (slipstream). Even in this case, chances are that most users will rather use standard windows software to create the bootable CDs than mkisofs under Linux, [...]]]></description>
			<content:encoded><![CDATA[<p>Generally, the only reason for which you may need to create a bootable Windows CD is when you have updated the operating system installation files with the latest Service Pack (slipstream). Even in this case, chances are that most users will rather use standard windows software to create the bootable CDs than <a href="http://cdrecord.berlios.de/old/private/mkisofs.html">mkisofs</a> under Linux, but, even for this extremely rare case, here is how to accomplish this task.<br />
<span id="more-389"></span><br />
For the following operation the <strong>Linux native mkisofs</strong> <em>version 2.01</em> (or <strong>genisoimage</strong>), which is shipped with Fedora (and with every other Linux distribution), was used.</p>
<p>The Windows port of <strong>mkisofs</strong> and, generally, the <strong>Win32 binaries</strong> of all the utilities included in the <a href="http://cdrecord.berlios.de/old/private/cdrecord.html">cdrtools</a> package can be found in the <a href="http://www.student.tugraz.at/thomas.plank/index_en.html">Cdrtools: Win32 Binaries</a> page. Please note that the page also includes a Win32 binary version of the latest (unstable) version of cdrtools. It is highly recommended to use the latest <strong>stable</strong> version.</p>
<p>So, <strong>change to the directory</strong> that contains the Windows installation files and issue the following command:</p>
<pre class="console">
mkisofs \
    -b cdboot/msboot.img -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 \
    -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames \
    -V "WINSP" \
    -o ../winsp.iso .
</pre>
<p><strong>The above command ends with a dot (.)</strong>.</p>
<p>All of the above flags seem to be necessary in order to <strong>relax many of the ISO restrictions</strong>. For more information about each of them please refer to the mkisofs (or <strong>genisoimage</strong>) manual page (<code>man 8 mkisofs</code>).</p>
<p>This tip assumes that the boot image which is used in the Microsoft bootable CDs is available and that it has been placed in a <code>cdboot/</code> subdirectory under the windows installation files root dir:</p>
<pre class="codesnp">
.
    cdboot/msboot.img
    other_dir/some_other_file
    file1
    file2
</pre>
<p>I admit that this is a nasty workaround, but I didn&#8217;t have enough time to investigate why the <strong>-b</strong> option caused that much trouble. The path to the boot image which is supplied with the -b option is supposed to be a relative path to the path of the root directory of the windows files, which is our current directory, aka (<strong>.</strong>). But, everytime I placed the msboot.img outside the win files directory and used <code>-b ../msboot.img</code>, mkisofs complained with the following pesky error message:</p>
<pre class="codesnp">mkisofs: Uh oh, I cant find the boot image '../msboot.img' !</pre>
<p>It didn&#8217;t make any sense, so I did not bother any more with it. If you have any info on this or if I miss anything, which is rather possible since I have spent very little time with this, your feedback is appreciated.</p>
<p>The above command will produce an image of a bootable Windows CD, which will also contain the boot image. But, this should not be a problem in any case.</p>
<p>Note that the ISO image will be saved in the <strong>parent directory</strong> of the one that holds the Windows files.</p>
<p><strong>Note</strong>: How to integrate a service pack into a Windows OS is beyond the scope of this document. There are numerous guides out there that cover this topic in great detail.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/">How to create a Windows bootable CD with mkisofs</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2009/05/07/microsoft-releases-windows-7-rc-to-the-public/" rel="bookmark">Microsoft Releases Windows 7 RC to the Public</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/07/verify-a-burned-cddvd-image-on-linux/" rel="bookmark">Verify a burned CD/DVD image on Linux</a></li>
<li><a href="http://www.g-loaded.eu/2010/04/08/started-using-rdiff-backup-on-windows/" rel="bookmark">Started using rdiff-backup on Windows</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/08/linux-tips-pack-i/" rel="bookmark">Linux Tips &#8211; Pack I</a></li>
<li><a href="http://www.g-loaded.eu/2009/03/05/checking-on-windows-vista/" rel="bookmark">Checking on Windows Vista</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Print a Man Page</title>
		<link>http://www.g-loaded.eu/2007/03/05/print-a-man-page/</link>
		<comments>http://www.g-loaded.eu/2007/03/05/print-a-man-page/#comments</comments>
		<pubDate>Mon, 05 Mar 2007 15:22:36 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[GNOME]]></category>
		<category><![CDATA[Printing]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/03/05/print-a-man-page/</guid>
		<description><![CDATA[Reading a man page using a terminal application is easy, but I doubt if it would ever win a convenience award. Sometimes, it is necessary to print the man page. I can recommend two ways of doing this. First, using the -t switch, when launching the man command from a terminal, causes the man page [...]]]></description>
			<content:encoded><![CDATA[<p>Reading a man page using a terminal application is easy, but I doubt if it would ever win a convenience award. Sometimes, it is necessary to print the man page. I can recommend two ways of doing this.<br />
<span id="more-367"></span><br />
First, using the <strong>-t</strong> switch, when launching the <strong>man</strong> command from a terminal, causes the man page to be formatted in <strong>Postscript</strong>. Technically, it uses <code>groff</code> to perform the conversion. More information about this can be found within the man command&#8217;s manual page (<code>man 1 man</code>).</p>
<p>The Postscript output can be piped to <strong>lpr</strong> for printing in a CUPS printer. The following example prints the <code>iptables</code> manual page to the <em>HP690C</em> printer:</p>
<pre class="console">$ man -t iptables | lpr -P HP690C</pre>
<p>Alternatively, the output can be saved to a postscript file:</p>
<pre class="console">$ man -t iptables > iptables.ps</pre>
<p>More on using a CUPS printer from the CLI can be found <a href="http://www.g-loaded.eu/2005/11/10/using-a-cups-printer-from-command-line/">here</a>.</p>
<p>Those who have the <a href="http://live.gnome.org/Yelp">Yelp</a> GNOME application installed, can take advantage of its internal man page parser and HTML converter. For example, in order to display the iptables man page in Yelp, launch it like the following:</p>
<pre class="console">$ yelp man:iptables</pre>
<p>From there, you can use the GNOME print dialog to print the iptables manual.</p>
<p>I tend to prefer the quality of the man page when it has been printed through Yelp.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/03/05/print-a-man-page/">Print a Man Page</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2005/11/10/print-to-cups-printer-instances/" rel="bookmark">Print to CUPS printer instances</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/using-a-cups-printer-from-command-line/" rel="bookmark">Using a CUPS printer from command line</a></li>
<li><a href="http://www.g-loaded.eu/2006/05/04/write-a-man-page/" rel="bookmark">Write A Man Page</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/23/use-python-to-get-the-web-page-data-in-epiphany/" rel="bookmark">Use Python to get the web page data in Epiphany</a></li>
<li><a href="http://www.g-loaded.eu/2006/12/03/pdf2email-cups-backend/" rel="bookmark">pdf2email CUPS Backend</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/03/05/print-a-man-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Error when using old run/bin installers under Linux</title>
		<link>http://www.g-loaded.eu/2007/02/25/error-when-using-old-runbin-installers-under-linux/</link>
		<comments>http://www.g-loaded.eu/2007/02/25/error-when-using-old-runbin-installers-under-linux/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 12:00:35 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Resolved]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/02/25/error-when-using-old-runbin-installers-under-linux/</guid>
		<description><![CDATA[I guess that every single *nix user, at least once, has run across files with the *.run or *.bin extensions. These scripts are usually software installers and are widely used to distribute, but not limited to, proprietary software to the Unix world. Examples are the popular NVidia or ATI display drivers for Linux and other [...]]]></description>
			<content:encoded><![CDATA[<p>I guess that every single *nix user, at least once, has run across files with the <code>*.run</code> or <code>*.bin</code> extensions. These scripts are usually software installers and are widely used to distribute, but not limited to, proprietary software to the Unix world. Examples are the popular <a href="http://www.nvidia.com/object/unix.html">NVidia</a> or <a href="http://ati.amd.com/support/driver.html">ATI</a> display drivers for Linux and other operating systems, the <a href="http://java.com/en/download/linux_manual.jsp">Sun Java Runtime Environment</a> etc. Recently, I encountered some issues when trying to use such installers.<br />
<span id="more-329"></span><br />
But first, some information about these scripts (installers). These are created with the <a href="http://www.megastep.org/makeself/">makeself</a> shell script, which actually creates self-extractable <code>tar.gz</code> archives. When launched, the installer does an archive integrity check and then extracts the included software to the desired location and performs all the programmed actions in order to make the installed software functional within the operating system.</p>
<p>Recently, I had to install the <a href="http://www.glub.com/products/secureftp/download.shtml">SecureFTP</a> ftp client for linux, but the script errored out with some strange messages like not being able to uncompress the archive or about not being able to verify the archive&#8217;s checksum or about wrong command line parameters used in some command calls internally. This had happened in the past too, when I wanted to install the good old game <a href="http://www.unrealtournament.com/utgoty/index.html">Unreal Tournament</a> (1999) so to revive some good memories. ;-)</p>
<p>Here are some of the weird error messages:</p>
<pre class="codesnp">
tail: cannot open `+187' for reading: No such file or directory
gunzip: stdin: not in gzip format
Verifying archive integrity...tail: cannot open `+6' for reading: No such file or directory
Error in check sums 1237260170 2341625838
</pre>
<p>As stated at the makeself website, archives created with Makeself older than v2.1.2 were using an old syntax for the <code>head</code> and <code>tail</code> Unix commands and there are problems uncompressing the included software.</p>
<p>In order to resolve this issue and make the installer &#8220;assume&#8221; that you use an old GNU/Linux version, you should export the following environment variable before using the installer:</p>
<pre class="console">export _POSIX2_VERSION=199209</pre>
<p>After you finish installing the software, delete that ENV variable:</p>
<pre class="console">unset _POSIX2_VERSION</pre>
<p>It took me a significant amount of time to learn about this workaround and, basically, I discovered it while searching for the software that creates these self-installing archives.</p>
<p>Hope this tip helps someone out there.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/02/25/error-when-using-old-runbin-installers-under-linux/">Error when using old run/bin installers under Linux</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/07/29/when-it-comes-to-error-messages/" rel="bookmark">When it comes to error messages&#8230;</a></li>
<li><a href="http://www.g-loaded.eu/2010/03/28/script-apache-error-report/" rel="bookmark">Script for Apache Error Report</a></li>
<li><a href="http://www.g-loaded.eu/2007/12/01/veritar-verify-checksums-of-files-within-a-tar-archive/" rel="bookmark">VeriTAR &#8211; Verify checksums of files within a TAR archive</a></li>
<li><a href="http://www.g-loaded.eu/2007/08/20/mailing-list-manager/" rel="bookmark">Mailing List Manager</a></li>
<li><a href="http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/" rel="bookmark">Email Notifications from a Linux System</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/02/25/error-when-using-old-runbin-installers-under-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>chroot Environment Howto</title>
		<link>http://www.g-loaded.eu/2007/02/21/chroot-environment-howto/</link>
		<comments>http://www.g-loaded.eu/2007/02/21/chroot-environment-howto/#comments</comments>
		<pubDate>Wed, 21 Feb 2007 14:45:04 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Slackware]]></category>
		<category><![CDATA[System]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/02/21/chroot-environment-howto/</guid>
		<description><![CDATA[The Slack World, a Slackware related online magazine has published a very good write-up about how to create a chroot environment. Tom Newsom writes in his article: In this document I shall be showing you how you can run, for testing purposes perhaps, two versions of Slackware simultaneously. Both will be fully fledged installs and [...]]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://slackworld.berlios.de/">The Slack World</a></em>, a <a href="http://www.slackware.com/">Slackware</a> related online magazine has published a very good write-up about how to create a chroot environment.</p>
<p><cite>Tom Newsom</cite> writes in his article:</p>
<blockquote><p>
In this document I shall be showing you how you can run, for testing purposes perhaps, two versions of Slackware simultaneously. Both will be fully fledged installs and both will be fully usable. It is possible to run other distributions via this method as well but I shall leave that aim as an exercise for the reader. Once you know how it is done then doing it for alternative distributions is a natural progression of your newly acquired skills.
</p></blockquote>
<p><a href="http://slackworld.berlios.de/2007/chroot_howto.html">Read the full article here</a></p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/02/21/chroot-environment-howto/">chroot Environment Howto</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/11/05/howto-run-vmware-on-a-physical-windows-partition/" rel="bookmark">Howto: Run VMWare on a Physical Windows Partition</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/05/ldap-howto/" rel="bookmark">LDAP HOWTO</a></li>
<li><a href="http://www.g-loaded.eu/2006/12/19/howto-dhcp-server-dhcpd-configuration/" rel="bookmark">Howto: DHCP Server (dhcpd) Configuration</a></li>
<li><a href="http://www.g-loaded.eu/2009/04/24/manually-prepare-the-rpm-building-environment/" rel="bookmark">Manually Prepare the RPM Building Environment</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/02/grub-repair-plus-installation-to-floppy/" rel="bookmark">GRUB repair plus installation to floppy</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/02/21/chroot-environment-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

