title: Python sys.argv out of range, don't understand why
body: <p>I have a script that I've been using for a some time to easily upload files to my server. It has been working great for a long time, but I can't get it to work on my new desktop computer.</p>
  <p>The code is simple:</p>
  <pre><code>import os.path
  import sys
  import os
  from ftplib import FTP
  
  host = &quot;&quot;
  acc = &quot;&quot;
  pw = &quot;&quot;
  filepath = sys.argv[1]
  
  if (not os.path.isfile(filepath)):
      x = input(&quot;ERROR, invalid filepath&quot;)
      exit()
  
  filename = os.path.basename(filepath)
  file_object = open(filepath, 'rb')
  
  ftp = FTP(host)
  ftp.login(acc, pw)
  ftp.storbinary('STOR ' + filename, file_object)
  ftp.quit()
  
  file_object.close()
  </code></pre>
  <p>I run it as:</p>
  <blockquote>
  <p>file_uploader.py backup.sql</p>
  </blockquote>
  <p>I get the following error:</p>
  <blockquote>
  <p>Traceback (most recent call last):</p>
  <p>File &quot;C:\Users\Admin\Desktop\file_uploader.py&quot;, line 12, in </p>
  <p>filepath = sys.argv[1]</p>
  <p>IndexError: list index out of range</p>
  </blockquote>
  <p>I'm not sure why it's giving me an error that it can't find the first commandline argument even though I passed one to the script.</p>
  <p>I am running Windows 7 64-bit with Python 2.7.2</p>
  <p>Thanks</p>