I decided to go ahead and use subprocess.call() and it works.
Python: using os.execlp() with the path being a variable
-
02-06-2022 - |
Domanda
I am converting a program from Batch to Python. Here is how I think I could do translate the Batch
%VBM% sharedfolder add %VMNAME% --name "LogDir" --hostpath %LogDir%
into:
os.execlp(VBM, 'sharedfolder', 'add', VMNAME, '--name', "LogDir",'--hostpath', LogDir)
My questions:
- Considering VBM, VMNAME, and LogDir are variables that are declared beforehand within my script, is my translation correct?
- Is it ok that I represent the Path string with a variable, e.g. VBM
- What could be a better way of doing any of the above?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow