I was trying to run the next command in my python code:
iostat -d 7 7 -p sda | awk '!/^Device/' | awk '!/^Linux/'
The way I tried it so far was this:
command = ["iostat", "-d", "7", "7", "-p", "sda", "|", "awk", "'!/^Device/'", "|", "awk", "'!/^Linux/'"]
device = subprocess.Popen(command, stdout=subprocess.PIPE)
devicetr = device.stdout.read()
It seems that the code won't handle the quotes marks in "'!/^Device/'"
and in "'!/^Linux/'"
like '!/^Device/'
and '!/^Linux/'
as intended.
When there is no USB connected, instead of blank I get this:
Linux 4.14.98-v7+ 01/28/2020 _armv7l_ (4 CPU)
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Tried already adding '\'
and this:
Passing double quote shell commands in python to subprocess.Popen()?