0

I know that it is possible to call/insert Bash/awk commands/scripts within a Python script, I found something like os.system('''awk '[...]''') and I suppose it works as well just for bash commands. The question is, how is it possible to pass, for instance, a Python list to these commands/this script?

1
  • 1
    Why do you want to do this? It's usually unnecessary, error-prone and makes your script less portable. Commented Feb 10, 2014 at 19:14

1 Answer 1

1

Strictly speaking, you cannot. You need to produce a string from the list which the recipient can use. For example:

lst = ['one', 'two', 'three']
os.system("bash myscript.sh " + " ".join(lst)) #  bash myscript.sh one two three 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.