![]() |
| ||
| executing scripts via command line Hello! I'm trying to execute a simple script in the command line, and for some reason, it's not working. Shouldn't it be as simple as this? python myscript.py And yet when I try that, I get "Syntax Error: invalid syntax" I've googled around, read through the docs--I have a feeling that this is probably something silly/small. Any help? Thanks! |
| ||
| Re: executing scripts via command line The syntax error is somewhere in your script. Can you post the script (or attach it) ? |
| ||
| Re: executing scripts via command line Ah, I see. So the actual command I was trying to execute was python controller.py I checked controller.py, and got an error message: Traceback (most recent call last): File "C:\Users\p\controller.py", line 3, in <module> exec "from " + sys.argv[1] + " import *" IndexError: list index out of range Here's the script: import sys There are other files (the "tichu" file it's importing from); let me know if you need to see more. |
| ||
| Re: executing scripts via command line Your problem is that sys.argv is what you supply on the command line after starting the script. So you would go python mycode.py arg1 arg2For yours to work you need at least 2 arguments for there to be sys.argv[1] |
| All times are GMT -4. The time now is 2:39 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC