在自动化测试中,经常会遇到一些程序需要运行在X windows环境下。
通常我会在shell脚本中用以下方法来运行脚本:
setup_vnc()
{
# start vnc number from 10 to avoid confilct with the exists.
VNC_DISPLAY=10
while ! vncserver :$VNC_DISPLAY
do
((VNC_DISPLAY++))
if [ $VNC_DISPLAY -gt 100 ]; then
echo "Create vnc sessions failed."
exit -1