Vignesh
Vignesh

Reputation: 952

Running Python script from bash: Command not found error

I Get command not found error. 0 and $filestem are the two args and I had the following in a script. And when i execute the script, I get command not found.

echo -e "Enter the file stem name"
read filestem
python gen_par_final.py 0 $filestem

The input files, the python script and the bash script are all in the same folder. the python script works at the command promt as such but not inside the script. Is there any path to be set or something that will resolve the problem?

Upvotes: 3

Views: 24950

Answers (2)

Sagar Rakshe
Sagar Rakshe

Reputation: 2840

This could work

  1. Insert this #! /usr/bin/Python at the top of gen_par_final.py file.
    (It's usually /usr/bin/python you need to check out how it's capital P)

  2. Make gen_par_final.py executable.
    $ chmod +x gen_par_final.py

  3. Edit your shell script.

    echo -e "Enter the file stem name"
    read filestem
    ./gen_par_final.py 0 $filestem

Upvotes: 5

tike
tike

Reputation: 2294

could /path/to/python ./gen_par_final.py 0 ${filestem} solve this?

I assume you checked for spelling errors?

Upvotes: 0

Related Questions