Reputation: 429
I want to run a python script from a shell script. I have been able to run it from the "command window" (Cygwin), but now I want to be able to call it from a shell script. It does not work the way I thought it would and the Internet has not really helped me with it.
My code so far:
#!/bin/bash
python Calibrate.py
I hope someone could help me further. Calibrate just contains a few basic command lines to transform some data that has been read in with an excelreader in the script itself.
Upvotes: 0
Views: 1254
Reputation: 55469
A Bash script needs to use the Unix EOL (End Of Line) convention, which terminates each line with \n
. But it looks like your test.sh shell script file uses the Windows / DOS EOL convention, which terminates each line with \r\n
.
You need to get rid of those \r
characters in test.sh, and you need to set your editor to use Unix line endings.
A simple way to strip \r
out of a file is to use the Unix sed
command; I assume it's available in Cygwin:
sed -i 's/\r//g' test.sh
This removes all \r
characters in test.sh, writing the result back to test.sh
Upvotes: 1
Reputation: 163
Just make sure the python executable is in your PATH environment variable, then add in your script
In the file job.sh,
#!/bin/sh
python <path/to/python/script>/python_script.py
Execute this command to make the script runnable for you : chmod u+x job.sh
Run it : ./job.sh
Upvotes: 1