Reputation: 217
I have a file named "uscf" in /usr/local/bin:
#! /bin/sh
python3 ~/Desktop/path/to/uscf.py
I have already chmod +x
this file so that I can run it from my terminal with the command "uscf
". How can I run this with command line arguments so that the arguments are accessible through sys.argv
in uscf.py?
EDIT: Added below example for clarification:
The uscf.py file:
import sys
if len(sys.argv) > 1:
print(sys.argv)
Running it from the command line:
Abraham$ uscf these are arguments
Expected output:
these are arguments
Upvotes: 0
Views: 185
Reputation: 34924
In sh the "$@" variable contains all the positional arguments passed to the script. You can use that to pass it to your python script:
#!/bin/sh
python3 $HOME/Desktop/path/to/uscf.py "$@"
Upvotes: 2