<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bandtank</id>
		<title>ProgrammingExamples - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bandtank"/>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Special:Contributions/Bandtank"/>
		<updated>2026-05-02T08:42:55Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Python</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Python"/>
				<updated>2012-09-22T21:51:54Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Python =&lt;br /&gt;
[http://python.org/ The Python programming language]&lt;br /&gt;
* Is [http://python.org/download/ Freely available]&lt;br /&gt;
* Runs [http://python.org/about/#python-runs-everywhere &amp;quot;everywhere&amp;quot;]&lt;br /&gt;
* Is interpreted (byte code compiled)&lt;br /&gt;
* Has efficient high level [http://docs.python.org/tutorial/datastructures.html data structures]&lt;br /&gt;
* Provides simple, effective [http://en.wikipedia.org/wiki/Object-oriented_programming object oriented programming]&lt;br /&gt;
* Has dynamic typing ([http://en.wikipedia.org/wiki/Duck_typing duck typing])&lt;br /&gt;
* Has an extensive [http://docs.python.org/library/index.html standard library] as well as many [http://pypi.python.org/pypi 3rd party additions]&lt;br /&gt;
* Is readily extensible using code written in C or C++&lt;br /&gt;
There is [http://docs.python.org/ extensive online documentation], including a [http://docs.python.org/tutorial/index.html tutorial].&lt;br /&gt;
----&lt;br /&gt;
=== Python Programming Examples ===&lt;br /&gt;
* [[Python/Smtplib|Send Emails with SMTP Library]]&lt;br /&gt;
* [[Python/ManyArgs|Handle many parameters under maintenance]]&lt;br /&gt;
* [[Python/UserPasswords|Getting a user name and (hidden text) password]]&lt;br /&gt;
* [[Python/DictAsSwitch|How to do a switch/case statement in Python]]&lt;br /&gt;
* [[Python/ThreePartOperator|How to mimic C's a = b ? b : c]]&lt;br /&gt;
* [[Python/Query MySQL databases using a custom class]]&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash</id>
		<title>Bash</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash"/>
				<updated>2012-02-16T22:04:11Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Bash/LoopOverFiles|Loop over files]]&lt;br /&gt;
* [[Bash/Parsing command line arguments using getopts|Parsing command line arguments using getopts]]&lt;br /&gt;
* [[Bash/Regular expression example using grep and sed|Regular expression example using grep and sed]]&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash</id>
		<title>Bash</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash"/>
				<updated>2011-10-05T16:42:56Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Bash/LoopOverFiles|Loop over files]]&lt;br /&gt;
* [[Bash/Parsing command line arguments using getopts|Parsing command line arguments using getopts]]&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts</id>
		<title>Bash/Parsing command line arguments using getopts</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts"/>
				<updated>2011-10-05T16:41:25Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: moved Bash/commandLineArgs to Bash/Parsing command line arguments using getopts&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Handling command line arguments can be done many ways, but few will be as elegant and streamlined as the built-in shell command called getopts. Note: getopt is the older version and should not be used as it is far less robust.&lt;br /&gt;
&lt;br /&gt;
Getopts shifts the data and sets an exit status of false when there is nothing left to do. Because of this behavior, getopts works well in a while loop as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
while getopts ...; do&lt;br /&gt;
  ...&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Often used in conjunction with getopts is the following conditional statement to force a certain number of arguments to be supplied:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#Check to see if the right number of arguments were supplied&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
  ...&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following script shows the usage of getopts. Getopts can't handle long options and will stop processing arguments when it hits the &amp;quot;--&amp;quot; argument (end of options). To specify an argument, the first letter of the word to be used as a switch is placed after the getopts command with an optional &amp;quot;:&amp;quot; if it also requires an additional parameter. An example program can be seen below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
#Set a default value for the $cell variable&lt;br /&gt;
cell=&amp;quot;test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Check to see if at least one argument was specified&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
   echo &amp;quot;You must specify at least 1 argument.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Process the arguments&lt;br /&gt;
while getopts c:hin: opt&lt;br /&gt;
do&lt;br /&gt;
   case &amp;quot;$opt&amp;quot; in&lt;br /&gt;
      c) cell=$OPTARG;;&lt;br /&gt;
      h) usage;;&lt;br /&gt;
      i) info=&amp;quot;yes&amp;quot;&lt;br /&gt;
      n) name=$OPTARG;;&lt;br /&gt;
      \?) usage;;&lt;br /&gt;
   esac&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example usages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
getopts_example.sh -c test1 -n test2&lt;br /&gt;
getopts_example.sh -c test3 -i&lt;br /&gt;
getopts_example.sh -h&lt;br /&gt;
getopts_example.sh -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 1 would assign &amp;quot;test1&amp;quot; to the $cell variable and &amp;quot;test2&amp;quot; to the $name variable.&lt;br /&gt;
&lt;br /&gt;
Example 2 would assign &amp;quot;test3&amp;quot; to the $cell variable, $name would not exist, and &amp;quot;yes&amp;quot; would be assigned to $info.&lt;br /&gt;
&lt;br /&gt;
Example 3 would call the usage function.&lt;br /&gt;
&lt;br /&gt;
Example 4 would cause getopts to display an error to stderr and then exit after calling the usage function.&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash/commandLineArgs</id>
		<title>Bash/commandLineArgs</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash/commandLineArgs"/>
				<updated>2011-10-05T16:41:25Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: moved Bash/commandLineArgs to Bash/Parsing command line arguments using getopts&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Bash/Parsing command line arguments using getopts]]&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts</id>
		<title>Bash/Parsing command line arguments using getopts</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts"/>
				<updated>2011-10-05T02:02:31Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Handling command line arguments can be done many ways, but few will be as elegant and streamlined as the built-in shell command called getopts. Note: getopt is the older version and should not be used as it is far less robust.&lt;br /&gt;
&lt;br /&gt;
Getopts shifts the data and sets an exit status of false when there is nothing left to do. Because of this behavior, getopts works well in a while loop as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
while getopts ...; do&lt;br /&gt;
  ...&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Often used in conjunction with getopts is the following conditional statement to force a certain number of arguments to be supplied:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#Check to see if the right number of arguments were supplied&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
  ...&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following script shows the usage of getopts. Getopts can't handle long options and will stop processing arguments when it hits the &amp;quot;--&amp;quot; argument (end of options). To specify an argument, the first letter of the word to be used as a switch is placed after the getopts command with an optional &amp;quot;:&amp;quot; if it also requires an additional parameter. An example program can be seen below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
#Set a default value for the $cell variable&lt;br /&gt;
cell=&amp;quot;test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Check to see if at least one argument was specified&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
   echo &amp;quot;You must specify at least 1 argument.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Process the arguments&lt;br /&gt;
while getopts c:hin: opt&lt;br /&gt;
do&lt;br /&gt;
   case &amp;quot;$opt&amp;quot; in&lt;br /&gt;
      c) cell=$OPTARG;;&lt;br /&gt;
      h) usage;;&lt;br /&gt;
      i) info=&amp;quot;yes&amp;quot;&lt;br /&gt;
      n) name=$OPTARG;;&lt;br /&gt;
      \?) usage;;&lt;br /&gt;
   esac&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example usages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
getopts_example.sh -c test1 -n test2&lt;br /&gt;
getopts_example.sh -c test3 -i&lt;br /&gt;
getopts_example.sh -h&lt;br /&gt;
getopts_example.sh -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 1 would assign &amp;quot;test1&amp;quot; to the $cell variable and &amp;quot;test2&amp;quot; to the $name variable.&lt;br /&gt;
&lt;br /&gt;
Example 2 would assign &amp;quot;test3&amp;quot; to the $cell variable, $name would not exist, and &amp;quot;yes&amp;quot; would be assigned to $info.&lt;br /&gt;
&lt;br /&gt;
Example 3 would call the usage function.&lt;br /&gt;
&lt;br /&gt;
Example 4 would cause getopts to display an error to stderr and then exit after calling the usage function.&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts</id>
		<title>Bash/Parsing command line arguments using getopts</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Bash/Parsing_command_line_arguments_using_getopts"/>
				<updated>2011-10-05T01:56:26Z</updated>
		
		<summary type="html">&lt;p&gt;Bandtank: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Handling command line arguments can be done many ways, but few will be as elegant and streamlined as the built-in shell command called getopts. Note: getopt is the older version and should not be used as it is far less robust.&lt;br /&gt;
&lt;br /&gt;
Getopts shifts the data and sets an exit status of false when there is nothing left to do. Because of this behavior, getopts works well in a while loop as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
while getopts ...; do&lt;br /&gt;
  ...&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Often used in conjunction with getopts is the following conditional statement to force a certain number of arguments to be supplied:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#Check to see if the right number of arguments were supplied&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
  ...&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following script shows the usage of getopts. Getopts can't handle long options and will stop processing arguments when it hits the &amp;quot;--&amp;quot; argument (end of options). To specify an argument, the first letter of the word to be used as a switch is placed after the getopts command with an optional &amp;quot;:&amp;quot; if it also requires an additional parameter. An example program can be seen below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
#Set a default value for the $cell variable&lt;br /&gt;
cell=&amp;quot;test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Check to see if at least one argument was specified&lt;br /&gt;
if [ $# -lt 1 ] ; then&lt;br /&gt;
   echo &amp;quot;You must specify at least 1 argument.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Process the arguments&lt;br /&gt;
while getopts c:hi: opt&lt;br /&gt;
do&lt;br /&gt;
   case &amp;quot;$opt&amp;quot; in&lt;br /&gt;
      c) cell=$OPTARG;;&lt;br /&gt;
      h) usage;;&lt;br /&gt;
      n) name=$OPTARG;;&lt;br /&gt;
      \?) usage;;&lt;br /&gt;
   esac&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example usages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
getopts_example.sh -c test1 -n test2&lt;br /&gt;
getopts_example.sh -c test3&lt;br /&gt;
getopts_example.sh -h&lt;br /&gt;
getopts_example.sh -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 1 would assign &amp;quot;test1&amp;quot; to the $cell variable and &amp;quot;test2&amp;quot; to the $name variable.&lt;br /&gt;
&lt;br /&gt;
Example 2 would assign &amp;quot;test3&amp;quot; to the $cell variable and $name would not exist.&lt;br /&gt;
&lt;br /&gt;
Example 3 would call the usage function.&lt;br /&gt;
&lt;br /&gt;
Example 4 would cause getopts to display an error to stderr and then exit after calling the usage function.&lt;/div&gt;</summary>
		<author><name>Bandtank</name></author>	</entry>

	</feed>