I'm trying to copy a file from a windows 10 host to an Ubuntu guest using the VirtualBox python SDK.
import vboxapi
SOURCE_PATH = r"K:\Downloads\first.sh"
DEST_PATH = r"/home/myuser/Downloads/first.sh"
UNAME = "myuser"
PASSWD = "mypass"
MACH_NAME = "Test"
virtualBoxManager = vboxapi.VirtualBoxManager(None, None)
vbox = virtualBoxManager.getVirtualBox()
todo = vbox.findMachine(MACH_NAME)
session = virtualBoxManager.getSessionObject(vbox)
progress = todo.launchVMProcess(session, "headless", None)
progress.waitForCompletion(-1)
console = session.console
runner = console.guest.createSession(UNAME, PASSWD, "", "")
print(runner.waitFor(virtualBoxManager.constants.GuestSessionWaitForFlag_Start, 0))
copy = runner.fileCopyToGuest(SOURCE_PATH, DEST_PATH, None)
copy.waitForCompletion(-1)
print(runner.fileExists(DEST_PATH, False))
console.powerDown()
# session.unlockMachine()
# virtualBoxManager.closeMachineSession(session)
However, the file does not get copied. Also, the following error is thrown when trying to check if the file exists.
Traceback (most recent call last): File "K:\WorkSpace\GOC\VBinit.py", line 18, in print(runner.fileExists(DEST_PATH, False)) File "C:\Users\kaust\AppData\Local\Temp\gen_py\3.7\D7569351-1750-46F0-936E-BD127D5BC264x0x1x3.py", line 3902, in FileExists , aFollowSymlinks) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'GuestSessionWrap', 'Querying file information for "/home/myuser/Downloads/first.sh" failed: VERR_BROKEN_PIPE', None, 0, -2135228411), None)
Why doesn't it work, and what changes should I make so that it does?