frazman
frazman

Reputation: 33213

simple bash script to execute python code

I am noob in bash script and I am trying to do the following..

I have a directory structure like

root/
root/execute.sh
root/python/foo.py

I want to execute foo.py I did something like following in execute.sh

#!/bin/sh
cd python
python foo.py

But it throws an error that foo.py is not there. How do i fix this?

Upvotes: 0

Views: 50

Answers (1)

pydvlpr
pydvlpr

Reputation: 321

In your script you should try

python ./foo.py 

Or you add the directory /root/python to root's PATH-variable. You can do this in the users .bashrc file by adding

PATH=$PATH:/root/python
export PATH

Hope that helps.

Best,

me

Upvotes: 2

Related Questions