I am trying to write a python file that takes command line input and performs some actions. The input will consist of a-z, [, ], ( and ). I made the following program just to check that I could keep going:
#!/usr/bin/env python
import sys
print str(sys.argv)
I did chmod +x program and tried calling ./program qwerty (abc) [hi] and it returned:
-bash: syntax error near unexpected token `('
Is there any way of changing the program so that it accepted parentheses in arguments?
Note: I have also tried placing square brackets before parentheses and it returns the same error.
()has special meaning to shell - it invokes the enclosed command in a subshell. Enclose your strings in double quotes to remove the special meaning -./program qwerty "(abc)" "[hi]"