When I try to execute a python script with arguments, the script fails and show the following error:
-bash: syntax error near unexpected token `"Lary",'
I try to execute the script like this:
display("Lary", 43, "M")
My code
#! /usr/bin/python
def display(name, age, sex):
print "Name: ", name
print "Age: ", age
print "Sex: ", sex
I try setting execute rights to the script (chmod 755 test.py) and I always get the same error.
What is wrong?
display("Lary", 43, "M"). And does the script work when you invoke it by doingpython test.py?/usr/bin/?#!/usr/bin/env python#!/usr/bin/env pythondisplay("Lary", 43, "M")inside the script and call it like./script_name.py. I guess bash is complaining because you are trying to use Python syntax on the command prompt.