-1

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.

asked Feb 16, 2018 at 20:22
8
  • 6
    Please define what you mean by "doesn't work". Do you get any output? How are you running your script? Commented Feb 16, 2018 at 20:24
  • 2
    What is the error message when you ran the bash script? Commented Feb 16, 2018 at 20:26
  • Possible duplicate of Call Python script from bash with argument Commented Feb 16, 2018 at 20:27
  • Which shell is your terminal running? What is the error message? Commented 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. Commented Feb 16, 2018 at 21:32

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

2 Comments

Why would this be necessary in the script, but not when he runs it by hand?
I have tried adding the path to python as well as the full path to the script. I still see no output or error messages when executing the bash script.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.