How to execute a script from Mac os to guest vm mac os.

Discussion in 'macOS Virtual Machine' started by XinB, Jan 29, 2020.

Tags:
  1. XinB

    XinB Bit poster

    Messages:
    1
    Hi guys. Thanks for your time.
    Im trying to use the Parallels python sdk prlsdkapi to execute a test script on guest vm mac os.
    I installed the parallel on mac book pro and installed a vm Mojave as guest os.
    Create a test.tet file under /Users/test/test.txt, content "haha"
    I'm trying to execute a script like /bin/cat /Users/test/test.txt to get "haha"
    Can anyone tell me how to do that.
    Below is what i did but didnt get answer.


    g_login = "test"
    g_password= "test"

    hArgsList = prlsdkapi.StringList()
    hArgsList.add_item("/bin/cat")
    hArgsList.add_item("/Users/test/test.txt")

    hEnvsList = prlsdkapi.StringList()
    hEnvsList.add_item("")
    try:
    vm_guest = vm.login_in_guest(g_login, g_password).wait().get_param()
    print("login success")
    except prlsdkapi.PrlSDKError as e:
    print("login Error: %s" % e)

    # Run the program.
    try:
    res = vm_guest.run_program("Terminal.app", hArgsList, hEnvsList).wait()
    params = res.get_param()
    event = params.get_param(0)

    except prlsdkapi.PrlSDKError as e:
    print("Error: %s" % e)
    # Logout from the virtual machine.
    vm_guest.logout().wait()
     

Share This Page