python subprocess calling bash script - need to print the quotes out too

前端 未结 3 723
你的背包
你的背包 2021-01-19 05:52

I\'m having a problem with subprocess and printing quotes.

My Python script takes user input, mashes it around a bit - and I need it to send it\'s results to a bash

3条回答
  •  忘掉有多难
    2021-01-19 06:20

    That's a list, those are strings in it, so they need quotes:

    ["myscript.sh", "var=11; ignore all", "/path/to/files"]
    

    That should work. If your script really somehow relies on quotes, then try this (I don't know the details of how subprocess works):

    ["myscript.sh", "'var=11; ignore all'", "/path/to/files"]
    

提交回复
热议问题