Basically, when you are running scripts [python / bash / sh] etc. you will need to check some specs before you run it, at this time the focus is on Python scripts.
#1 Check if the file has the specific “shebang” line as first line of the script.
What is “shebang” ? It’s a simple line that act as variable into the script to indicate the location of the Python interpreter on the system.
Note: Check the syntax, if does not have the correct order it will fail.
#2 Check permissions of the script, the script will need execute permissions.
-rwxr-xr-x. 1 root root 0 Jan 31 00:12 extract_rules.py
You can assign execute permissions to the script with the following command,
[root@localhost ~]# chmod +x filename.extension
Note: Extension, because the command works to assign execute permissions to any type of scripts.
[root@localhost ~]# chmod +x extract_rules.py
#3 Now you only need to run the script, to do that just type the word “python” at the beginning of the script you want to run and wait until the task is done. That will invoke the python interpreter located on the specific path we used as shebang.
[root@localhost ~]# python extract_rules.py