Just make sure the python executable is in your PATH environment variable then add in your script
python path/to/the/python_script.py
Details:
- In the file job.sh, put this
#!/bin/sh python python_script.py
- Execute this command to make the script runnable for you :
chmod u+x job.sh - Run it :
./job.sh
What's the difference between python and python shell?
To all experts: Shell as a scripting language vs Python as a scripting language
How does Python compare to traditional shell scripting languages like Bash?
Can I execute shell commands directly from Python scripts?
How can I optimize Python shell scripts for performance?
Videos
Just make sure the python executable is in your PATH environment variable then add in your script
python path/to/the/python_script.py
Details:
- In the file job.sh, put this
#!/bin/sh python python_script.py
- Execute this command to make the script runnable for you :
chmod u+x job.sh - Run it :
./job.sh
Method 1 - Create a shell script:
Suppose you have a python file hello.py
Create a file called job.sh that contains
#!/bin/bash
python hello.py
mark it executable using
$ chmod +x job.sh
then run it
$ ./job.sh
Method 2 (BETTER) - Make the python itself run from shell:
Modify your script hello.py and add this as the first line
#!/usr/bin/env python
mark it executable using
$ chmod +x hello.py
then run it
$ ./hello.py
I recently learnt that shell is a programming language (here) and terminal is a graphical emulator. We use the shebang #!to tell the shell what to use to run the script. For example, if we want to run a py script
#!/usr/bin/env python
If shell itself is another programming language, why do we have to "tell" the shell what interpreter to use if we are using some other language like python? Do all the languages parse everything to shell and then run the script? What's the difference between python and python shell? Does every language have a shell?
My take:
Python is probably a great language(what I saw and importantly, used for very little time), but that never enticed me to stick with it on a long-term basis.
See! The shortcoming and understanding. Some conventions in that language look and importantly, feel ridiculous.
My lacuna ...so I refrained from it as much as possible. That certainly does NOT demean Python's ability.
Shell is comparatively easy (take it with a pinch of salt :) ) to learn and use. And it certainly has some eye-popping drawbacks. But the world used to run on it and still some do.
What do you use more frequently?
PS: There is a catch, for the month-end paycheck you are force to use something, that you might not like. I am ignoring that "important fact" in this argument. Looking for pure technical merits.