I have a python script that takes a file as argument through sys.argv.
What is the best way to pass this file as a logic in Linux?
I have tried to add this line of code on the first line of my Python script, thinking that I can drag on it and drag files, but it does not seem to work.
#! / Usr / bin / env dragon
Am I missing something? Cheers
Python script.py file name
line #! / Usr / bin / env python
is the Shebang line.
If you make your script an executable (i.e., to convert it to a file's executable to use chmod
), identify the type of Shebang script Helps in
The path to an alternative Shebang python
is used directly #! / Usr / bin / python
, but the path may vary on different machines and therefore we usually get the path to the bindery from env
.
Shebang is not required if you run the script with python script.py
, OK, but if the script is referenced somewhere, then causing this problem Could.
Note that the extension .py
is completely optional, and for this, I add one Shebang to all my scripts, to ensure that from within my editor What is this script?
./ script
in large projects to achieve the task; This humility ensures that executable scripts can be in dragon, bash or any other scripting language, until it does so. No, you can not drag and drop a file even if it is executable even for the Python script as an absolute.
Comments
Post a Comment