问题
I'll get right into the point. The problem is:
- my localmachine is a Windows OS
- I launched a Windows Virtual Machine (through VirtualBox) that awaits some python commands
- on my localhost I have a python script that I execute and
- after the VM is started, I want the script to open inside the VM, a cmd.exe process
- after cmd.exe opens up, the python script should send to that cmd.exe, inside the VM, the delete command "
del c:\folder_name
"
I did searched on various issue on StackOverflow that suggested me using subprocess.call
or subprocess.Popen
, but unfortunately none of them worked in my case, because I'm sure that all of the solutions were meant to work on localhost, and not inside a virtual machine, how I want it.
Any suggestions? Thank you.
PS: I'm trying to do this without installing other packages in host/guest.
UPDATE: Isn't there any solution, that will allow me to do this without installing something on VM ?!
回答1:
You can install an ssh server on the Windows machine and then use the paramiko module to communicate with it or you can also use wmi command to remotely execute command on Windows system.
来源:https://stackoverflow.com/questions/33345609/send-a-dos-command-in-a-virtual-machines-cmd-through-python-script