Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Shell脚本OSX-VM融合(VMRun)_Macos_Shell_Virtual Machine - Fatal编程技术网

Macos Shell脚本OSX-VM融合(VMRun)

Macos Shell脚本OSX-VM融合(VMRun),macos,shell,virtual-machine,Macos,Shell,Virtual Machine,我正在尝试创建一个shell脚本来检查VM是否在OSX上运行如果它当前没有运行我想启动它,我有办法检查它是否正在运行,如果它没有运行,我有办法启动它。我没有的是语法,使所有的工作。。。感谢您的帮助: 命令1 只有在VMFusion上运行活动VM时,才会返回“.vmx”。我想使用此命令,并使其有条件与此命令对应使用: 命令2 这将启动虚拟机 逻辑是: infinite loop { Command 1 If the return of the Command 1 is not ".vmx

我正在尝试创建一个shell脚本来检查VM是否在OSX上运行如果它当前没有运行我想启动它,我有办法检查它是否正在运行,如果它没有运行,我有办法启动它。我没有的是语法,使所有的工作。。。感谢您的帮助:

命令1 只有在VMFusion上运行活动VM时,才会返回“.vmx”。我想使用此命令,并使其有条件与此命令对应使用:

命令2 这将启动虚拟机

逻辑是:

infinite loop
{
Command 1
If the return of the Command 1 is not ".vmx"
then run Command 2
else 
do nothing
continue looping
}

你的意思是:

while true; do
    command_one=$(/Applications/VMware\ Fusion.app/Contents/Library/vmrun list | grep -q \".vmx\")
    if [ $command_one = ".vmx" ]; then
        $(/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion start \"PATHTOVMXFILE/Windows 7.vmx\")
    else
        sleep 1;
    fi
done

基本上,伙计,谢谢你,我唯一要改变的是,如果命令_one!=',它将执行命令。vmx“但我认为我能处理这部分!感谢您的帮助。太好了。如果它对您有效,也许您可以将其标记为已解决?Thnx!完成。再次感谢。
infinite loop
{
Command 1
If the return of the Command 1 is not ".vmx"
then run Command 2
else 
do nothing
continue looping
}
while true; do
    command_one=$(/Applications/VMware\ Fusion.app/Contents/Library/vmrun list | grep -q \".vmx\")
    if [ $command_one = ".vmx" ]; then
        $(/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion start \"PATHTOVMXFILE/Windows 7.vmx\")
    else
        sleep 1;
    fi
done