2015-11-02 63 views
4

我试图通过VirtualBox vboxmanage guestcontrol提供的命令行界面运行/bin/ls未知子命令:使用guestcontrol选项时'执行'

this documentation,我运行这些命令:

vboxmanage startvm centos6; 
vboxmanage guestcontrol "centos6" execute --image "/bin/ls" --username root --passwordfile pwd.txt --wait-exit --wait-stdout -- -l /usr; 

我有以下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'

回答

5

是似乎并执行(Execute)不与最新的5.0.10版本的工作了的VirtualBox。尝试使用'run'而不是'execute'和'--exe'而不是'--image'。

此外 - 等待退出已被抑制。

这里是我现在用的是命令: $ 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"

该命令在执行OS/X,以便与三个参数在Windows 64位执行批处理文件foo.bat。第二个参数'f:'是与我的程序所在的OS/X目录相对应的Windows frive。 在我的情况下,这个批处理文件使用windows'cmake'来在Windows 64上编译一个C程序。它是交叉编译的替代方案,有时更好,因为您可以使用性能更高的本地编译器,并且可以在真实环境中测试可执行文件。但是,'run --- exe'与以前的'execute --image'有所不同,因为如果命令在终端shell中运行良好,我会在使用'compile'命令的emacs下遇到困难,可能是因为 - 等待退出不再存在。难度在于VirtualBox虚拟机运行CPU消耗量高,并且不会停止。但从bash来看,它看起来与以前非常相似。

VBoxManage的当前文档压制了'execute'和'--image',但使用过时(并且没有更多工作)选项的旧例子仍然存在,不幸的是增加了混淆。

更新:在VirtualBox的5(我的是5.2.6),我在做 $ 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"

启动直接在64位CMD.EXE没有工作了。