我有一个Windowsbatch file下面的命令,每当我运行上述批处理(ipconfig.bat)获得我的Linux虚拟机的IP,它输出的IP罚款,但不结束batch file,我必须按控制+ c,然后按“y”结束batch file。 即使添加了@exit它也不会退出。
VBoxManage --nologo guestcontrol execute "nixvm" "/root/scripts/ipconfig.sh" --username root --password mypassword --verbose --wait-for stdout @exit
有什么build议么 ?
Bash脚本(由windowsbatch file执行)
#!/bin/bash echo "IP Address of "LinuxVM" ifconfig eth0 | egrep '(inet addr|RX bytes|TX bytes)' sleep 1s #echo "MySQL Service Status" service mysql status chkconfig mysql --list sleep 1s #echo "Displaying MySQL DBs" mysqlshow -uroot -pmypassword
Windowsbatch file
VBoxManage --nologo guestcontrol execute "LinuxVM" "/root/scripts/ipconfig.sh" --username root --password password --verbose --wait-for stdout
您可以使用--timeout来提供以毫秒为单位的超时时间,告诉VBoxManage等待脚本退出的时间。
VBoxManage --nologo guestcontrol execute "nixvm" "/root/scripts/ipconfig.sh" --username root --password mypassword --verbose --timeout 10000 --wait-for stdout