I have a basic script called script.sh which will take 3 parameters, each a python file. I need to run these programs within script.sh. I have

#! usr/bin/env python3

for my first line, and I've tried running each of the programs with python ${1} as well as python3 ${1}. I'm new to scripting; is it possible to run these programs within my script?

  • If the python scripts are marked executable, just call them by their name (no explicit python/python3) needed.
    – xenoid
    Commented Feb 24, 2020 at 0:06
  • Is script.sh meant to be a shell script or a python script? Commented Feb 24, 2020 at 0:49
  • script.sh is a shell script. Also, when I removed the python/python3 and just had ${1} it gives me a syntax error for that line.
    – Jake
    Commented Feb 24, 2020 at 0:56
  • If it's a shell script, then it should start with the shebang of a regular shell interpreter, such as #!/bin/sh or #!/bin/bash. The shell will then execute your python commands. Commented Feb 24, 2020 at 2:50

2 Answers 2


Did you mean to add a slash to the start of the path, as in #!/usr/bin/env python3? The path must be reachable from the working directory, and having a usr/bin/env in a project is unlikely, to say the least.

As for how to run it: if you actually want to use the shebang line interpreter the file must be executable and you must run the script as just /path/to/script.py (or ./path/to/script.py). As soon as you put a python or python3 in front of the path that command is going to be used as the interpreter.


if you mean to run python scripts via a shell script using shell CLAs you can try this one


CLAString=$@ #Copying the CL arguments to a string

varlen=${#CLAString} #finding the no of CL args

if [[ $varlen -gt 0 ]] #if no of CL args is not zero
python ${1}.py # run first CLA python script

execute this by ./script.sh file1 file2 file3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .