<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eTechTips</title>
	<atom:link href="http://www.etechtips.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.etechtips.com</link>
	<description>Your Technical resource</description>
	<lastBuildDate>Mon, 27 Feb 2012 16:11:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Python: Handle Command line arguments</title>
		<link>http://www.etechtips.com/2012/02/23/python-handle-command-line-arguments/</link>
		<comments>http://www.etechtips.com/2012/02/23/python-handle-command-line-arguments/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 23:41:03 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=634</guid>
		<description><![CDATA[Here is my basic script for handling command line arguments in Python(pre version 2.7 when optparse was deprecated). The optparse library is very useful in not only handling the command line arguments, but setting up your help menu as well. You will need to create an OptionParser and the usage argument lets you print the [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my basic script for handling command line arguments in Python(pre version 2.7 when optparse<br />
was deprecated).  The optparse library is very useful in not only handling the command line<br />
arguments, but setting up your help menu as well. </p>
<p>You will need to create an OptionParser and the usage argument lets you print the usage statement<br />
for the script.  Then you can add options, add groups for options or collect the left over<br />
parameters as a secondary command or list of files.  I use this method often as I create scripts<br />
that help automate build processes. </p>
<pre>
#!/usr/bin/python

import sys, optparse

# This creates an OptionParser object with the usage string.
op = optparse.OptionParser(usage=" %prog [options]")
# This will add an option -m or --mode which takes sets the mode variable as
# True or False
op.add_option("-m","--mode",help="Specify the mode for the command",
            action="store_true", dest="mode",default=False)
# This parses the options and places the selected options above in the _options
# object and the rest in arguments.
_options,arguments = op.parse_args()

# Checks if no arguments are passed and if so, runs the print_help method of
# the OptionParser object
if len(sys.argv) == 1:
    op.print_help()

# This was just to show what happened when you did or didn't pass the
# --mode argument.
if  _options.mode:
    print "Mode is on"
else:
    print "Mode is off"
</pre>
<p>This method is currently deprecated as of version 2.7.  I will write a follow-up post that uses<br />
the newer argparse routine to highlight any differences.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/02/23/python-handle-command-line-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DOS: Capture return values from commands</title>
		<link>http://www.etechtips.com/2012/02/08/dos-capture-return-values-from-commands/</link>
		<comments>http://www.etechtips.com/2012/02/08/dos-capture-return-values-from-commands/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 03:31:41 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=628</guid>
		<description><![CDATA[When I am writing build automation scripts, there are times that I have to insure that the previous command completed with no errors. I have found that ERRORLEVEL gets filled in with the return value from a command. dir %1 if (%ERRORLEVEL%) == (0) echo Found File: %1 if (%ERRORLEVEL%) == (1) echo Missing File: [...]]]></description>
			<content:encoded><![CDATA[<p>When I am writing build automation scripts, there are times that I have to insure that the previous command completed<br />
with no errors. I have found that ERRORLEVEL gets filled in with the return value from a command.</p>
<pre>
dir %1

if (%ERRORLEVEL%) == (0) echo Found File: %1
if (%ERRORLEVEL%) == (1) echo Missing File: %1
</pre>
<p>So if you save the previous in a file and run the command with one (1) argument, it will display the output of the dir command<br />
but also print either &#8220;Found file: <filename>&#8221; or &#8220;Missing File: <filename>&#8220;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/02/08/dos-capture-return-values-from-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3DSMax: Remove background image</title>
		<link>http://www.etechtips.com/2012/02/01/3dsmax-remove-background-image/</link>
		<comments>http://www.etechtips.com/2012/02/01/3dsmax-remove-background-image/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 06:33:59 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[3DSMax]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=617</guid>
		<description><![CDATA[So in 3DSMax it is sometimes useful to insert a background image usually when you are modelling something and using the background image as a guide. There is no easy way to remove it. You can reassign another image or set it to not display the background image, but this can lead to problems if [...]]]></description>
			<content:encoded><![CDATA[<p>So in 3DSMax it is sometimes useful to insert a background image usually when you are modelling<br />
something and using the background image as a guide.  There is no easy way to remove it.  You<br />
can reassign another image or set it to not display the background image, but this can lead to<br />
problems if the file is moved or removed as it is still linked to your max file.</p>
<p>MaxScript to the rescue!  You can use the MaxScript Listener(F11) to type in the following to<br />
clear the background filename:</p>
<pre>
backgroundimagefilename=""
</pre>
<p>This will clear the entry for the filename.  I have noticed that you do need to exit 3DSMax to<br />
fully make the change complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/02/01/3dsmax-remove-background-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: error when using the input() function</title>
		<link>http://www.etechtips.com/2012/01/20/python-error-when-using-the-input-function/</link>
		<comments>http://www.etechtips.com/2012/01/20/python-error-when-using-the-input-function/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 17:38:24 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=610</guid>
		<description><![CDATA[I was writing a basic guessing game and when I tried to take user input I was getting the following: Code: guess = input() d Error: Traceback (most recent call last): File "", line 1, in File "", line 1, in NameError: name 'd' is not defined The problem is actually with the version of [...]]]></description>
			<content:encoded><![CDATA[<p>I was writing a basic guessing game and when I tried to take user input I was<br />
getting the following:</p>
<p>Code:</p>
<pre>
guess = input()
d
</pre>
<p>Error:</p>
<pre>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'd' is not defined
</pre>
<p>The problem is actually with the version of Python that I was using.  If you<br />
are using Python 2.x, you need to use the raw_input() function. And with 3.x<br />
you can use the input() function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/01/20/python-error-when-using-the-input-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: if/else Statements</title>
		<link>http://www.etechtips.com/2012/01/20/python-ifelse-statements/</link>
		<comments>http://www.etechtips.com/2012/01/20/python-ifelse-statements/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 16:25:47 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=601</guid>
		<description><![CDATA[There comes a time when you are writing a program and you need to branch based on input to a program. This is the format of the if/else statement in Python. if &#60;some true/false statement&#62; : &#60;some statements that run if the if statement is true&#62; else: &#60;some other statements that run if the if [...]]]></description>
			<content:encoded><![CDATA[<p>There comes a time when you are writing a program and you need to branch based on input to a program.<br />
This is the format of the if/else statement in Python.  </p>
<pre>
if &lt;some true/false statement&gt; :
  &lt;some statements that run if the if statement is true&gt;
else:
  &lt;some other statements that run if the if statement are false&gt;
</pre>
<p>There may be times when you have more than one value set to test against.  In that case you can write a many if/else<br />
statements but you can chain the if/else statements with an elif.  So the chain becomes if/elif/else.</p>
<pre>
if x < 5:
  &lt;some statements that run if the if statement is true&gt;
elif x > 5 and x < 10:
  &lt;some statements that run if the elif statement is true&gt;
else:
  &lt;if none of the if checks are true, run the statements in the else case.&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/01/20/python-ifelse-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: Allow for empty if else blocks</title>
		<link>http://www.etechtips.com/2012/01/20/python-allow-for-empty-if-else-blocks/</link>
		<comments>http://www.etechtips.com/2012/01/20/python-allow-for-empty-if-else-blocks/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 16:15:28 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=605</guid>
		<description><![CDATA[I was toying with a prime number finder and was creating a set of if/else statements for a horribly failed attempt and wanted to skip to the next number on any of the if statements that were true. I didn&#8217;t want to put an empty print statement as that would disrupt the output I was [...]]]></description>
			<content:encoded><![CDATA[<p>I was toying with a prime number finder and was creating a set of if/else statements for a horribly failed attempt<br />
and wanted to skip to the next number on any of the if statements that were true.  I didn&#8217;t want to put an empty print<br />
statement as that would disrupt the output I was expecting from the program.  I found the pass statement.<br />
Here is an example from my not very successful attempt at finding primes:</p>
<pre>
if inp > 2 and inp % 2 == 0:
  pass
elif inp > 3 and inp % 3 == 0:
  pass
elif inp > 7 and inp % 7 == 0:
  pass
elif inp > 9 and inp % 9 == 0:
  pass
else:
  print inp, " is a prime"
</pre>
<p>Yes, this does not accurately find the primes, but it would skip any number that is divisible by 2,3,5,7, or 9.  And<br />
anything that does not match this will be listed as a prime, this is incorrect and would be made to add new elif<br />
statements as each prime was found.   </p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/01/20/python-allow-for-empty-if-else-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C: Check if string is a number</title>
		<link>http://www.etechtips.com/2012/01/10/c-check-if-string-is-a-number/</link>
		<comments>http://www.etechtips.com/2012/01/10/c-check-if-string-is-a-number/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 16:04:44 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=595</guid>
		<description><![CDATA[I was recently testing some basic input and wrote this code to test if the input was a number or not. #include int main() { char name[10]; scanf("%s",&#038;name); if (checkifNumber(name)) { printf("Is a number\n"); } else { printf("Invalid number\n"); } } int checkifNumber(char *inp) { int i=0; int isanumber = 1; while(inp[i] != '\0' &#038;&#038; [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently testing some basic input and wrote this code to test if the input was a number or not.</p>
<pre>
#include <stdio.h>

int main()
{
  char name[10];

  scanf("%s",&#038;name);
  if (checkifNumber(name))
  {
     printf("Is a number\n");
  }
  else
  {
     printf("Invalid number\n");
  }
}

int checkifNumber(char *inp)
{
  int i=0;
  int isanumber = 1;

  while(inp[i] != '\0' &#038;&#038; i < 10)
  {
    if (inp[i] >= '0' &#038;&#038; inp[i] <= '9')
    {
    }
    else
    {
      isanumber =0;
    }
    i++;
  }
  return isanumber;
}
</pre>
<p>One thing that could be improved is to potentially use a global variable to define the length of the<br />
input string as it is used in two different places in the program and could potentially lead to an<br />
array overrun/underrun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2012/01/10/c-check-if-string-is-a-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dos: Adding commands to the PATH</title>
		<link>http://www.etechtips.com/2011/12/20/dos-adding-commands-to-the-path/</link>
		<comments>http://www.etechtips.com/2011/12/20/dos-adding-commands-to-the-path/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 20:45:47 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[DOS]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=589</guid>
		<description><![CDATA[When you install a new piece of software that does not add itself to the Windows PATH variable, you may find your self needing it to be run from a command prompt. You could type the full command path each time you run the executable, but it may be easier to add the directory to [...]]]></description>
			<content:encoded><![CDATA[<p>When you install a new piece of software that does not add itself to the Windows PATH variable, you may find your self<br />
needing it to be run from a command prompt. You could type the full command path each time you run the executable, but<br />
it may be easier to add the directory to the PATH variable so that it is always available.</p>
<p>To add it for the current command prompt:</p>
<pre>set PATH=%PATH%;"C:\Program Files\Sometool"</pre>
<p>This will add the variable to the current command prompt environment but will go away once you close the window and will not<br />
be available to other prompts unless you type it in again.</p>
<p>To add it to the Windows Environment, you can use the My Computer-&gt;Properties menu to select the &#8220;Advanced System Settings&#8221;<br />
in Windows 7 to then select the &#8220;Environment Variables&#8230;&#8221;. Now the choice you have is to add it to the System variables or<br />
the User variables for.</p>
<p>If you choose the System varables you will be adding it to the system as a whole and any other user who logs in will have<br />
the updated path. If you add it to the User variables, then it is only available to your user.</p>
<p>Whichever you choose, select the Path entry and click the &#8220;Edit&#8230;&#8221; button. This will pop up a dialog that will let<br />
you add to the &#8220;Variable Value&#8221; entry. Now you will need to decide whether you want your new path at the beginning, end,<br />
or somewhere in the middle. You might add it to the beginning if it is being used to override an existing command. You<br />
may add to the end if there is no conflict with other installs. And finally, you may need to choose the middle if there<br />
are some commands you need to override but others that need to be left alone.</p>
<p>Entries are separated by the semi-colon &#8220;;&#8221; character in DOS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/12/20/dos-adding-commands-to-the-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl: Format date strings</title>
		<link>http://www.etechtips.com/2011/12/07/perl-format-date-strings/</link>
		<comments>http://www.etechtips.com/2011/12/07/perl-format-date-strings/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 19:48:57 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=586</guid>
		<description><![CDATA[The other day I had a requirement to fill in a date value while creating an entity in ClearQuest. The field that was required was a date and was formatted as &#8220;mm/dd/yyyy hh:MM::SS AM&#124;PM&#8221;. I used the localtime function to return the date and used sprintf to format the date to the proper output. The [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I had a requirement to fill in a date value while creating an entity in ClearQuest.  The field that was required was a date and was formatted as &#8220;mm/dd/yyyy hh:MM::SS AM|PM&#8221;.  I used the localtime function to return the date and used sprintf to format the date to the proper output.<br />
The reason I used sprintf was that for hours, months and days less 10 the output was 1 digit instead of two and the input was not allowed.  The %02d states that the digits used will be a minumum of 2 in this case.</p>
<p>Here is the sample program I wrote to test the expected output:</p>
<pre>
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;

# formatted just by concatenating output
my $datestring = $mon . "/" . $mday . "/" . $year . "  " . $hour . ":" . $min.
":" . $sec  ;

# formatted using sprintf to ensure proper digit counts are output
my $datestring2 = sprintf("%02d/%02d/%04d %d:%02d:%02d %s",$mon,$mday,1900 +$yea
r,$hour,$min,$sec, $hour >= 12? "PM" : "AM");

 print $datestring;
  print $datestring2;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/12/07/perl-format-date-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Rsync to backup a directory</title>
		<link>http://www.etechtips.com/2011/11/21/using-rsync-to-backup-a-directory/</link>
		<comments>http://www.etechtips.com/2011/11/21/using-rsync-to-backup-a-directory/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 23:40:11 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=168</guid>
		<description><![CDATA[Recently I was moving data between an old server and new web server. I had some 250 GB of data and thought about just using Secure Copy (scp). When I started the process, I walked away thinking &#8220;No Problem&#8221;, but after a few files, I got an error due to file permissions and I did [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was moving data between an old server and new web server.  I had some 250 GB of data and thought about just using Secure Copy (scp).  When I started the process, I walked away<br />
thinking &#8220;No Problem&#8221;, but after a few files, I got an error due to file permissions and I did not want to figure out what files had not been copied yet or where to try to restart.<br />
   So I used rsync to mirror the drive.  I was able to set it up and due to my slow network speed, it still took several days, but I was certain that I had gotten all the data.</p>
<pre>
rsync -azuv -e ssh  user@originserver:public_html/* public_html/
</pre>
<p>The options I used were for :</p>
<table cellpadding="3" bgcolor="white">
<tr>
<td>Option</td>
<td>Description</td>
</tr>
<tr>
<td>-a</td>
<td>Archive Mode</td>
</tr>
<tr>
<td>-z</td>
<td>Compress File Data</td>
</tr>
<tr>
<td>-u</td>
<td>Update Mode</td>
</tr>
<tr>
<td>-v</td>
<td>Verbose</td>
</tr>
<tr>
<td>-e <command></td>
<td>specify command to run</td>
</tr>
</table>
<p>This took some time to run, but I did not have to babysit the command and it duplicated the data from my old server to the new one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2011/11/21/using-rsync-to-backup-a-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

