os.system (cmd /all >file) gives an empty file, if i run the command directly in the command prompt I am getting the output to text file

378 views Asked by At

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 answers

0
Emmanuel DUMAS On

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