0

If my shell variable is like the following ( key value separated by spaces ). Example below:

$ var="key1=value1 key2=value2"

$ python3 create_user.py abc ${var}

['create_user.py', 'abc', 'key1=value1', 'key2=value2']

It is treating each key-value as a separate argument.

But, i am looking for is the following outcome from variable.

['create_user.py', 'abc', 'key1=value1 key2=value2']

Essentially, i want the second argument $var to be treated as a string in single quote.

SunilS
  • 2,030
  • 5
  • 34
  • 62

1 Answers1

1
#if you do not change shell script
import sys
second_arg = sys.argv[2]+' '+sys.argv[3]
#or, change shell script accordingly (did not test it..)
$ var="'key1=value1 key2=value2'"
$ python3 create_user.py abc ${var}
#than
import sys
second_arg = sys.argv[2]