2

I'm getting a list out of range error from sys.argv[1] and I tried making a simple script with this code.

import sys
print sys.argv

I get this on cmd:

C:\...\...\...\py>back.py exampleargv
['C:\\...\\...\\...\\py\\back.py']

I don't know why I don't get the next arg.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
biosr
  • 65
  • 3
  • Is that a typo. The script name is back.py but it prints backdoor.py? – Himanshu Jul 30 '14 at 02:30
  • This makes no sense. Your script is called `back.py` but the script outputs that its name is `backdoor.py`. Please post accurate code and results and then we can help. – mhawke Jul 30 '14 at 02:31
  • 2
    Must be Windows specific. Works fine for me on OS X and Ubuntu :) – tsaulic Jul 30 '14 at 02:33

1 Answers1

5

It's a windows specific problem: try "python back.py examplearg" and it will work.

Solution (besides not running Windows!) is to update your registry.

http://eli.thegreenplace.net/2010/12/14/problem-passing-arguments-to-python-scripts-on-windows/

Set these keys = value

HKEY_CLASSES_ROOT\Applications\python26.exe\shell\open\command = "C:\Python26\python26.exe" "%1" %*

HKEY_CLASSES_ROOT\py_auto_file\shell\open\command = "C:\Python26\python26.exe" "%1" %*

sp00n3r
  • 654
  • 5
  • 10