I am trying to find all the VM's running using "vmrun list" command and i want the output in the text file.

import os
os.system("C:\\Program\ Files\ (x86)\\VMware\VMware\ VIX\\vmrun /all >C:\\Users\\xyz\\Documents\\qw.txt ")

When i run the same command in the command prompt i am getting a file with the command prompt output, but when i do the same thing in python i am getting an empty file. What can i do to get the output to the file from python script??

1

There are 1 best solutions below

0
On

You should have a look on subprocess module , by example command getoutput.