User interaction between host and virtual machine

大城市里の小女人 提交于 2019-12-11 20:34:52

问题


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

来源:https://stackoverflow.com/questions/15632026/user-interaction-between-host-and-virtual-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!