I am trying to run a for loop that goes through each line of the output of a command. For ex:
for line in exec 'lspci | grep VGA':
count = count + 1
To try and get the amount of video cards installed in a system. But it doesn’t seem to line the syntax on the for loop line.
Do I have to import a library for exec? Or am I using it wrong? Or both?
Thanks
execexecutes Python code, not an external command. You’re looking forsubprocess.Popen():On my box, this prints out