I have been searching for an answer to no avail. I have a python script that I would like to run that has quite a few arguments. It works just fine when I run the command from the terminal, but as soon as I try to put it in a bash script it no longer works.
script.py --arg1 --arg2 --arg3 --arg4 --arg5
This works.
#!/bin/bash
script.py --arg1 --arg2 --arg3 --arg4 --arg5
This does not. I get no error message or output.
-
6Please define what you mean by "doesn't work". Do you get any output? How are you running your script?0x5453– 0x54532018年02月16日 20:24:58 +00:00Commented Feb 16, 2018 at 20:24
-
2What is the error message when you ran the bash script?yaobin– yaobin2018年02月16日 20:26:04 +00:00Commented Feb 16, 2018 at 20:26
-
Possible duplicate of Call Python script from bash with argumentsgc– sgc2018年02月16日 20:27:47 +00:00Commented Feb 16, 2018 at 20:27
-
Which shell is your terminal running? What is the error message?cdarke– cdarke2018年02月16日 20:31:41 +00:00Commented Feb 16, 2018 at 20:31
-
What I meant by doesn't work is I get no output or error message. If I append an echo 'Done' to the bash script, I never see the Done output.jchan– jchan2018年02月16日 21:32:06 +00:00Commented Feb 16, 2018 at 21:32
1 Answer 1
Try this
#!/bin/bash
python script.py --arg1 --arg2 --arg3 --arg4 --arg5
The above assumes python executable is present in your path. If it is not you could also use the full path to python as follows
#!/bin/bash
/usr/bin/python script.py --arg1 --arg2 --arg3 --arg4 --arg5
answered Feb 16, 2018 at 20:32
Farooq Khan
5884 silver badges11 bronze badges
Sign up to request clarification or add additional context in comments.
default