internalerror404
internalerror404

Reputation: 81

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.

Upvotes: 3

Views: 4965

Answers (3)

THAVASI.T
THAVASI.T

Reputation: 181

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

Upvotes: 0

internalerror404
internalerror404

Reputation: 81

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 %*

Upvotes: 1

vikramls
vikramls

Reputation: 1822

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.

Upvotes: 2

Related Questions