shell script not executing a python file
<p>I am trying to run a script which in turn should execute a basic python script.
This is the shell script:</p>

<pre><code>#!usr/bin/bash
mv ~/Desktop/source/movable.py ~/Desktop/dest
cd ~/Desktop/dest
pwd
ls -lah
chmod +x movable.py
python movable.py
echo "Just ran a python file from a shell script"
</code></pre>

<p>This is the python script:</p>

<pre><code>#!usr/bin/python
import os
print("movable transfered to dest")
os.system("pwd")
os.system("mv ~/Desktop/dest/movable.py ~/Desktop/source")
print("movable transfered to dest")
os.system("cd ~/Desktop/source")
os.system("pwd")
</code></pre>

<p>Q1. The shell script is not executing the python file. What am I doing wrong?
Q2. Do I need to write the first line <code>#!usr/bin/python</code> in the python script?
Thank you.</p>

<p>You are missing a '/' in the shebang line:</p>

<pre><code>#!usr/bin/python
</code></pre>

<p>should be</p>

<pre><code>#!/usr/bin/python
</code></pre>

<p>Another thing I noticed was, you are calling cd in os.system.  Since that command would be executed in a sub shell, it won't change the current directory of the calling script process.</p>

python shell