0

I have a shell script that calls various python scripts and passes an argument it got onto the python scripts. However, the python scripts are currently not getting the argument. when i go to sys.argv it instead shows something completely different. I have the code and sys.argv below:

Shell Script (called run_everything.sh) :

#!/bin/bash

source venv/bin/activate

python3 eval_otare_on_otare.py $1

then i have a line in eval_otare_on_otare.pt that prints the arguments passed: print(sys.argv)

And I get the following list:

['eval_care_on_otare.py', 'run_everything.sh']

what can I do because sys.argv is clearly not getting what I want, I want it to return

['eval_care_on_otare.py', $1]

where $1 is the argument passed

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 2
    Are you sure you used `$1` and not `$0` in the bash script? – Barmar Jul 25 '22 at 17:11
  • Perhaps add some echo's or other prints in your bash script to confirm that $1 is the parameter you want. – PaulD Jul 25 '22 at 17:24
  • Your script is clearlyea [tag:bash] script; thus I removed the [tag:sh] tag. See also [Difference between sh and bash](https://stackoverflow.com/questions/5725296/difference-between-sh-and-bash) – tripleee Jul 26 '22 at 03:57

1 Answers1

0

If your activate script messes up the value of $1, save it first.

#!/bin/bash

arg=$1

source ./venv/bin/activate

python3 eval_otare_on_otare.py "$arg"

Tangentially note also When to wrap quotes around a shell variable?

tripleee
  • 175,061
  • 34
  • 275
  • 318