首页 > 解决方案 > 如何使用 Windows cmd 行中的 vboxmanage cli 将参数传递给 shell/bash 脚本?

问题描述

我有一个在 Oracle Virtual box 中运行的 VM。在这个 VM 中,我有一些 bash/shell 脚本,并且还定义了一些全局变量,例如export abc=123

vm中的脚本,

#!/bin/bash 
echo testing
echo $abc

在 vm 中,如果我使用我运行此脚本,则bash test.sh输出为

testing
123

如果我从 windows 命令提示符下运行命令,我会得到testing输出,但我没有得到123. 我只是在输出中得到一个空格。我的 vboxmanage 命令如何获取在我的 vm.xml 中abc定义的变量的值。

testing 

windows cli中的命令,

VBoxManage guestcontrol vm-name run /bin/sh --exe  "test.sh" --username user --password pass --verbose --wait-stdout --wait-stderr

标签: bashpowershellshellvirtualboxpowershell-2.0

解决方案


推荐阅读