Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
 
should it not be read $filestem ? –  karthikr Jun 17 '13 at 21:44
 
@karthikr: - no - –  doukremt Jun 17 '13 at 21:45
 
If you modify the code above to take no arguments then do you get the same error? Just trying to see if your python script it broken or the way you handle arguments. –  arajek Jun 17 '13 at 21:50
 
I did remove the args and ran the code. It still gives me error. –  Vignesh Jun 17 '13 at 22:00
2  
I have found that aliases aren't always found in a shell script. Try using /usr/bin/Python and see if that works in your script. You might want to figure out why python was installed with a capital letter. –  SethMMorton Jun 17 '13 at 22:52
show 5 more comments

2 Answers

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

share|improve this answer
 
I tried this. while executing it gives me a area selection type cursor and this error import: unable to grab mouse `': Resource temporarily unavailable @ xwindow.c/XSelectWindow/8969. –  Vignesh Jun 18 '13 at 15:14
 
Check if this works on terminal $ ./gen_par_final.py 0 <sample_arg>. –  Sagar Rakshe Jun 18 '13 at 17:23
add comment

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

I assume you checked for spelling errors?

share|improve this answer
 
The explicit path doesn't solve the problem too. –  Vignesh Jun 17 '13 at 22:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.