I am trying to run /bin/ls
through the command-line interface provided by VirtualBox vboxmanage guestcontrol
.
Following this documentation , i run those commands :
vboxmanage startvm centos6;
vboxmanage guestcontrol "centos6" execute --image "/bin/ls" --username root --passwordfile pwd.txt --wait-exit --wait-stdout -- -l /usr;
I've got the following stdout
:
Oracle VM VirtualBox Command Line Management Interface Version 5.0.0 (C) 2005-2015 Oracle Corporation All rights reserved.
Usage:
VBoxManage guestcontrol [--verbose|-v] [--quiet|-q] [--username ] [--domain ] [--passwordfile | --password ]
run [common-options] [--exe <path to executable>] [--timeout <msec>] [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args] [--ignore-operhaned-processes] [--no-profile] [--no-wait-stdout|--wait-stdout] [--no-wait-stderr|--wait-stderr] [--dos2unix] [--unix2dos] -- <program/arg0> [argument1] ... [argumentN]] start [common-options] [--exe <path to executable>] [--timeout <msec>] [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args] [--ignore-operhaned-processes] [--no-profile] -- <program/arg0> [argument1] ... [argumentN]] copyfrom [common-options] [--dryrun] [--follow] [-R|--recursive] <guest-src0> [guest-src1 [...]] <host-dst> copyfrom [common-options] [--dryrun] [--follow] [-R|--recursive] [--target-directory <host-dst-dir>] <guest-src0> [guest-src1 [...]] copyto [common-options] [--dryrun] [--follow] [-R|--recursive] <host-src0> [host-src1 [...]] <guest-dst> copyto [common-options] [--dryrun] [--follow] [-R|--recursive] [--target-directory <guest-dst>] <host-src0> [host-src1 [...]] mkdir|createdir[ectory] [common-options] [--parents] [--mode <mode>] <guest directory> [...] rmdir|removedir[ectory] [common-options] [-R|--recursive] <guest directory> [...] removefile|rm [common-options] [-f|--force] <guest file> [...] mv|move|ren[ame] [common-options] <source> [source1 [...]] <dest> mktemp|createtemp[orary] [common-options] [--secure] [--mode <mode>] [--tmpdir <directory>] <template> stat [common-options] <file> [...]
VBoxManage guestcontrol [--verbose|-v] [--quiet|-q]
list <all|sessions|processes|files> [common-opts] closeprocess [common-options] < --session-id <ID> | --session-name <name or pattern> <PID1> [PID1 [...]] closesession [common-options] < --all | --session-id <ID> | --session-name <name or pattern> > updatega|updateguestadditions|updateadditions [--source <guest additions .ISO>] [--wait-start] [common-options] [-- [<argument1>] ... [<argumentN>]] watch [common-options]
Syntax error: Unknown sub-command: 'execute'
Yes the execute doesn't seem to work anymore with latest 5.0.10 version of VirtualBox. Try using 'run' instead of 'execute' and '--exe' instead of '--image'.
Also --wait-exit has been suppressed.
Here is a command which I am now using:
$ VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" foo.bat --username myname --verbose --wait-stdout --wait-stderr -- "/c" "f:\path\foo.bat" "arg1" "f:" "arg3"
The command is executed on OS/X in order to execute on a Windows 64bit a batch file foo.bat with three arguments. The second argument, 'f:', is the windows frive which corresponds to the OS/X directory where my program resides. In my case, this batch file is using windows 'cmake' in order to compile on Windows 64 a C program. It is an alternative to cross-compilation and sometimes better because you can use a native compiler with greater performance and you can test your executable in its real environment.
However, 'run ---exe' is somehow different from former 'execute --image' because if the command works well in a terminal shell, I encounter difficulties under emacs with 'compile' command, probably because --wait-exit doesn't exist anymore. Difficulty is that VirtualBox VM is running with high CPU consumption and doesn't stop. But from bash, it looks very similarly as before.
Current documentation of VBoxManage suppressed 'execute' and '--image' but older examples using the obsolete (and no more working) options are still there, increasing confusion unfortunately.
Update: On VirtualBox 5 (mine is 5.2.6), I am doing
$ VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\\Windows\\system32\\cmd.exe" foo.bat --username myname --verbose --wait-stdout --wait-stderr -- "C:\Windows\SysWOW64\cmd.exe" "/c" "f:\path\foo.bat" "arg1" "f:" "arg3"
Launching directly the 64bit cmd.exe didn't work anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With