'How can I forward command line arguments in a shell script? [duplicate]
My goal is to run a shell script on my Mac Terminal that passes command line arguments to a python script. I know how to do it on Windows:
Batch file (pythonScript.bat):
@py.exe C:\path\to\my\pythonScript.py %*
@pause
The %* forwards any command line arguments entered after the batch filename to the Python script. So when I run pythonScript.bat from the command line...
C:\> pythonScript
...the arguments I enter after the batch filename (for example C:> pythonScript some arguments) are passed to the python script.
How can I do that on my Mac?
How can I complement my code so that any command line arguments are forwarded to the python script?
Shell script (pythonScript.command):
#!/usr/bin/env bash
python3 /path/to/my/pythonScript.py
Solution 1:[1]
in Linux bash I would do:
#!/usr/bin/env bash
python3 /path/to/my/pythonScript.py "$@"
$@ is interpreted as the list of arguments passed to the bash script.
I haven't got a mac to test it, but worth trying it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Charles Duffy |
