Keep all your executable files in a folder, I usually keep it in /home/pi/
. Your folder can be called for example exec
mkdir exec
move your Python3 script into this folder:
mv myScript.py ~/exec/
In your myScript.py
add the shebang line on the top-most part of script
$ nano myScript.py
## add this line on top of file
!/usr/bin/python3
CTRL+O then press Enter and in the end CTRL+X
give executable rights to your file:
$ chmod +x myScript.py
Additional : you can also remove the .py
from the file and keep it just myScript
mv myScript.py myScript
You have your script as an executable you can trigger it by doing a simple
./myScript
Pausing Scripts
I think this is inherent to the script you have written, you can use time.sleep
in your script to pause the working and do something in the meantime for e.g. print something or do nothing.
Adding Arguments
You can use configParser
module in Python to give arguments to your script
Your executable will now run as:
./myScript -arg1 -arg2
Links
Python3 ConfigParser
time.sleep() for Pausing Python scripts
Edit:
Parse Flags to a Python Executable
python3 -i blahblah.py
.