'Run a python script in the guest virtual machine using vmrun runScriptInGuest
I am trying to run a very long python script which resides in guest virtual machine A.py from the host linux machine. The guest VM is Windows 7x64 and application is VMware Fusion.
I am using following command:
vmrun -T ws -gu <username> -gp <password> runScriptInGuest "/Users/userdir/Documents/Virtual Machines.localized/Windows7x64.vmwarevm/Windows7x64.vmx" C:\\Users\\Admin\\Documents\\A.py C:\Python27\python.exe
This is not working. Any ideas on how to get this working?
I really appreciate your help.
Solution 1:[1]
Just a wild guess, but try changing the order of the last 2 arguments:
vmrun -T ws -gu -gp runScriptInGuest "/Users/userdir/Documents/Virtual Machines.localized/Windows7x64.vmwarevm/Windows7x64.vmx" C:\Python27\python.exe C:\Users\Admin\Documents\A.py
The Python interpreter should be invoked by the VM and the interpreter will run the A.py
script.
Solution 2:[2]
vmrun -T ws -gu Admin -gp Apple1984 runProgramInGuest "/Users/userdir/Documents/Virtual Machines.localized/Windows7x64.vmwarevm/Windows7x64.vmx" -activeWindow "C:\Users\\Admin\A.bat"
where A.bat is a bat file where I invoke python script
@echo off
cd C:\Users\Admin
C:\python27\python.exe A.py %*
Solution 3:[3]
try the pip module. vmrunPacked this pkg use to vm take control. start, stop, snapshot create, revert, delete. inside file run. both of all execute.
vmrunPacked tool use run the A.py script
pip install vmrunPacked
install this package
import vmrunPacked
#assgin vm object
vmobj = vmrunPacked.Pack("/vmx_file_path/vm.vmx",userName="admin",passWord="admin@123")
# start the vm
vmobj.start()
# run the ruby script file in inside vm
interpreter_path = "C:\\Program Files\\Ruby\\ruby.exe"
file_path = "D:\\new\\init.rb"
vmobj.run_script_in_guest(interpreter_path, file_path)
read the document vmrunPacked
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vikramls |
Solution 2 | evandrix |
Solution 3 | THAVASI.T |