how to execute a python program in a shell script

Shell script should be like:

#!/bin/sh
python disk.py

To be able to execute as ./disk.py you need two things:

  1. Change the first line to this: #!/usr/bin/env python
  2. Make the script executable: chmod +x disk.py

As @SHW mentioned, the question actually asks about executing a python program in a shell script (not running the python script directly with ./disk.py)

So, expanding on @SHW answer, your shell script should be like:

#!/bin/bash
/usr/bin/python /absolute/path/to/your/disk.py

Notice the /usr/bin/python instead of just python; using absolute paths helps the script to know exactly what python to use (to find the absolute path to your installed python use which python).

Same story when using absolute paths with your python script instead of just disk.py. In my case, I was trying to run a Django app from my bash script, so I had to add the absolute path of my manage.py for it to run correctly.

Also, regarding the header of your bash script, there are several alternatives to #!/bin/bash. Please, take a look at this question to know more about it.

Cheers.