Jan-24-2024, 07:13 AM
Save the following in your bash script folder as, for example, helloWorld.sh
Now run the helloWorld.sh in bash as below, and the Python programme helloWorld.py will run.
Below is what you see in bash when you run helloWorld.sh:
Like I said, helloWorld.sh and helloWorld.py must both be executable.
Don't forget the shebang at the top of your Python programme: #! /usr/bin/python3
Quote:# this is a bash script
echo "This is bash speaking, I am now starting helloWorld.py"
# put the path to your Python programme here
myPython/helloWorld.py
Now run the helloWorld.sh in bash as below, and the Python programme helloWorld.py will run.
Below is what you see in bash when you run helloWorld.sh:
Quote:pedro@pedro-HP:~$ helloWorld.sh
This is bash speaking, I am now starting helloWorld.py
This is Python speaking: Hello World
What is your name?
Peter
It is good to meet you,Peter
pedro@pedro-HP:~$
Like I said, helloWorld.sh and helloWorld.py must both be executable.
Don't forget the shebang at the top of your Python programme: #! /usr/bin/python3