<?xml version="1.0" encoding="UTF-8"?><!-- generator="lyceum/1.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Python for Bash scripters:  A well-kept secret</title>
	<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/</link>
	<description>Red Hat Magazine</description>
	<pubDate>Thu, 24 Jul 2008 15:57:23 +0000</pubDate>
	<generator>http://lyceum.ibiblio.org/?v=1.0.2</generator>

	<item>
		<title>by: OldPro</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-105507</link>
		<pubDate>Sat, 12 Jul 2008 10:10:39 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-105507</guid>
					<description>I tried to use python, converting several bash tools but I am not convinced. Python is a full-fledged programming language and maybe not a bad one. But BASH scripts look much cleaner if you want to glue together bricks of binaries and shell scripts. As soon as your BASH script looks too complicated, it should be converted into a regular (non-shell) language with heavy type checking and strict compilation settings.

The fact that in Python I need to import some class "subprocesses" (dependency hell!!!) to do even the most menial of things, that I should embed code into Popen etc. is appalling to me: the full Unix power is transparently in your hands within BASH. As a rule in programming, the necessary and complicated data structures should always be hidden under the hood, i.e., within data files etc. Shell programming is about handling named chunks of information in a processing line, possibly using pipes to avoid the over-use of temporary files. Sadly, this simplicity is lacking in all of the script-use examples of Python I see on the web.

The importing of modules/classes was a hell in Tcl/Tk, it is in Java and it is in Python. My juniors are losing a lot of time in getting things to work on any other machine ("but the .py worked perfectly on mine!").

Let's keep it simple wherever it can.

By the way: the line 
echo "$cmd"
will NOT execute the command in the BASH sequence example. 
</description>
		<content:encoded><![CDATA[<p>I tried to use python, converting several bash tools but I am not convinced. Python is a full-fledged programming language and maybe not a bad one. But BASH scripts look much cleaner if you want to glue together bricks of binaries and shell scripts. As soon as your BASH script looks too complicated, it should be converted into a regular (non-shell) language with heavy type checking and strict compilation settings.</p>
<p>The fact that in Python I need to import some class &#8220;subprocesses&#8221; (dependency hell!!!) to do even the most menial of things, that I should embed code into Popen etc. is appalling to me: the full Unix power is transparently in your hands within BASH. As a rule in programming, the necessary and complicated data structures should always be hidden under the hood, i.e., within data files etc. Shell programming is about handling named chunks of information in a processing line, possibly using pipes to avoid the over-use of temporary files. Sadly, this simplicity is lacking in all of the script-use examples of Python I see on the web.</p>
<p>The importing of modules/classes was a hell in Tcl/Tk, it is in Java and it is in Python. My juniors are losing a lot of time in getting things to work on any other machine (&#8221;but the .py worked perfectly on mine!&#8221;).</p>
<p>Let&#8217;s keep it simple wherever it can.</p>
<p>By the way: the line<br />
echo &#8220;$cmd&#8221;<br />
will NOT execute the command in the BASH sequence example.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: www.tagsto.com/trackback/</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-83746</link>
		<pubDate>Sun, 11 May 2008 17:57:41 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-83746</guid>
					<description>&lt;strong&gt;Hubs of Python for Bash scripters: A well-kept secret&lt;/strong&gt;

hubs about Administration IRIX to ... “Python For *Nix Systems Administration,” (working title) due sometime in 2008. He works as a software engineer for Racemi, dealing with Bash, Python, SNMP and a slew of *nix operating systems, including AIX, H...</description>
		<content:encoded><![CDATA[<p><strong>Hubs of Python for Bash scripters: A well-kept secret</strong></p>
<p>hubs about Administration IRIX to &#8230; “Python For *Nix Systems Administration,” (working title) due sometime in 2008. He works as a software engineer for Racemi, dealing with Bash, Python, SNMP and a slew of *nix operating systems, including AIX, H&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: PEdroArthur_JEdi</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-56398</link>
		<pubDate>Sun, 02 Mar 2008 13:32:15 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-56398</guid>
					<description>Just a little tip...

count=$((count + 1))

Do you think this is messy?
so, code like this:

((count++))</description>
		<content:encoded><![CDATA[<p>Just a little tip&#8230;</p>
<p>count=$((count + 1))</p>
<p>Do you think this is messy?<br />
so, code like this:</p>
<p>((count++))
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Noah Gift</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-54316</link>
		<pubDate>Sat, 16 Feb 2008 14:23:19 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-54316</guid>
					<description>If you find yourself not having subprocess, you can use popen:

http://docs.python.org/lib/module-popen2.html
</description>
		<content:encoded><![CDATA[<p>If you find yourself not having subprocess, you can use popen:</p>
<p><a href="http://docs.python.org/lib/module-popen2.html" rel="nofollow">http://docs.python.org/lib/module-popen2.html</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Wannabe</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-54271</link>
		<pubDate>Sat, 16 Feb 2008 08:28:13 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-54271</guid>
					<description>the "subprocess" module is specific to the newest version of python. The version that came with my system doesn't have it, but the version I compiled myself does.</description>
		<content:encoded><![CDATA[<p>the &#8220;subprocess&#8221; module is specific to the newest version of python. The version that came with my system doesn&#8217;t have it, but the version I compiled myself does.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Don Seiler</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-53803</link>
		<pubDate>Wed, 13 Feb 2008 21:52:07 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-53803</guid>
					<description>@Charlie, I noticed the same thing with "cmds" vs "commands".  I'd like to see a correction in the article if anyone is paying attention.</description>
		<content:encoded><![CDATA[<p>@Charlie, I noticed the same thing with &#8220;cmds&#8221; vs &#8220;commands&#8221;.  I&#8217;d like to see a correction in the article if anyone is paying attention.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ajay</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52981</link>
		<pubDate>Sat, 09 Feb 2008 09:17:56 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52981</guid>
					<description>dabbling with shell every now and then (I ma not a shell ninja by any means), I have not come across an elegant error handling solution so far.
(If someone has it will be nice if you can point me to some documentation/tutorial)

This starts biting you in case you have large shell scripts (even if broken down to functions) and every line ends with "&#124;&#124; die" where die spits some debug info and as the name suggests dies.

Python/ruby can be be helpful here, as they have better error handling mechanisms in try/catch/finally

however, I will stick to shell for my one liners 
- "pipe is mans best friend"</description>
		<content:encoded><![CDATA[<p>dabbling with shell every now and then (I ma not a shell ninja by any means), I have not come across an elegant error handling solution so far.<br />
(If someone has it will be nice if you can point me to some documentation/tutorial)</p>
<p>This starts biting you in case you have large shell scripts (even if broken down to functions) and every line ends with &#8220;|| die&#8221; where die spits some debug info and as the name suggests dies.</p>
<p>Python/ruby can be be helpful here, as they have better error handling mechanisms in try/catch/finally</p>
<p>however, I will stick to shell for my one liners<br />
- &#8220;pipe is mans best friend&#8221;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Paddy3118</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52943</link>
		<pubDate>Sat, 09 Feb 2008 04:44:24 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52943</guid>
					<description>At work we use this excellent tool to manage multiple versions of all types of software - just install to a different area and create a module to update your environment to access the version of Python you require:
  http://modules.sourceforge.net/

I could then do:
  module load python/2.5.1
  python -V;   # shows its python 2.5.1
  module rm python
  module load python/2.4
  python -V;   # shows its python 2.4

- Paddy.</description>
		<content:encoded><![CDATA[<p>At work we use this excellent tool to manage multiple versions of all types of software - just install to a different area and create a module to update your environment to access the version of Python you require:<br />
  <a href="http://modules.sourceforge.net/" rel="nofollow">http://modules.sourceforge.net/</a></p>
<p>I could then do:<br />
  module load python/2.5.1<br />
  python -V;   # shows its python 2.5.1<br />
  module rm python<br />
  module load python/2.4<br />
  python -V;   # shows its python 2.4</p>
<p>- Paddy.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Michael DeHaan</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52906</link>
		<pubDate>Fri, 08 Feb 2008 22:56:19 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52906</guid>
					<description>Noah's examples strike me as more of examples of baby steps to doing things, rather than examples that simply replace shell script one liners in their own right.  So if you are new to Python syntax, read them over, but don't take them as boilerplate.  For instance, he showed you how to use optparse and subprocess -- now imagine their usage in a more complicated program :)

If you want to see another interesting systems management project using Python that may appeal to bash+ssh users BTW, check out Func -- https://fedorahosted.org/func.  There should a Red Hat Magazine article on it coming out pretty soon now too.   

(I see Smooge has already alluded to it... and yes, he's a bit right regarding versioning.  Typically I target my stuff at a base of Python 2.3 and avoid newer functions in 2.4/2.5 -- such is the case with many toolsets.  That's more of an issue of coding to the distro though, than the language itself... or in coding to the API of various libraries that are no longer updated for older platforms).


</description>
		<content:encoded><![CDATA[<p>Noah&#8217;s examples strike me as more of examples of baby steps to doing things, rather than examples that simply replace shell script one liners in their own right.  So if you are new to Python syntax, read them over, but don&#8217;t take them as boilerplate.  For instance, he showed you how to use optparse and subprocess &#8212; now imagine their usage in a more complicated program :)</p>
<p>If you want to see another interesting systems management project using Python that may appeal to bash+ssh users BTW, check out Func &#8212; <a href="https://fedorahosted.org/func." rel="nofollow">https://fedorahosted.org/func.</a>  There should a Red Hat Magazine article on it coming out pretty soon now too.   </p>
<p>(I see Smooge has already alluded to it&#8230; and yes, he&#8217;s a bit right regarding versioning.  Typically I target my stuff at a base of Python 2.3 and avoid newer functions in 2.4/2.5 &#8212; such is the case with many toolsets.  That&#8217;s more of an issue of coding to the distro though, than the language itself&#8230; or in coding to the API of various libraries that are no longer updated for older platforms).
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Noah Gift</title>
		<link>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52902</link>
		<pubDate>Fri, 08 Feb 2008 22:00:34 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/#comment-52902</guid>
					<description>Everyone who commented/Thank you so much, there are many excellent points, that I agree with them mostly.  If anyone has a better example of the Bash or Python scripts, send me an email noah dot gift at gmail dot com.  I will add you to the google code project and you can check in more examples of your own.  At worst it is something fun to do on a weekend:

http://code.google.com/p/python4bash/


</description>
		<content:encoded><![CDATA[<p>Everyone who commented/Thank you so much, there are many excellent points, that I agree with them mostly.  If anyone has a better example of the Bash or Python scripts, send me an email noah dot gift at gmail dot com.  I will add you to the google code project and you can check in more examples of your own.  At worst it is something fun to do on a weekend:</p>
<p><a href="http://code.google.com/p/python4bash/" rel="nofollow">http://code.google.com/p/python4bash/</a>
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
