User interaction between host and virtual machine

2019-09-17 06:04发布

问题:

I have a python script on my host machine which is trying to run another script in the guest machine. I also want the script on host to feed the script on guest with a number.

On host machine:

args = shlex.split("vmrun -gu root -gp mohsen77 runProgramInGuest F:/Attacker/Ubuntu1110.vmx /usr/bin/python /home/srastega/Attacker")
Attacker = subprocess.Popen(args, stdin=PIPE, stderr=STDOUT, stdout=PIPE)
out, err = Attacker.communicate("1\n")
exitcode = Attacker.returncode

On guest machine:

n= int(raw_input("Value for n:"))
t = open('/home/srastega/test', 'a')
t.write("%s"%str(n))

Unfortunately, Guest program exited with non-zero exit code:1 (the error seen on host machine). But, if I try these two scripts in one machine the communication is working properly and the first script passes number "1" to the second script which writes that number into a file.

Any idea how to interact between host and guest machine? Thanks, Samaneh