我正在编写一个脚本来在许多基于 debian 的设备上设置 VNC(除其他外)。我想在此设置中包含 VNC(具体来说,如果可能,请使用tightVNC)并让它设置一个给定的密码(由脚本随机生成)。问题是,我找到的每个指南似乎都假设人类正在这样做,并准备坐下来输入密码并按回车键。我似乎无法让 Bash 向 VNC 回显密码(它总是说“密码太短”),也无法让“期望”正常工作。
我发现的示例指南如下所示: http ://www.penguintutor.com/linux/tightvnc
我正在寻找类似的东西:
#!/bin/bash
echo "Going to configure VNC"
#turn on vnc server
tightvncserver
#spit out password to vnc server for first run only
echo $password
#confirm the pw
echo $password
但是,在每次紧身 vncserver 的原始运行中,它总是要求手动输入密码:
Going to configure VNC
You will require a password to access your desktops.
Password: Password too short
我如何#1 解决这个问题,或者#2 使用 bash / 期望给它一个密码来让它开心?