gpt4 book ai didi

linux - ubuntu 14.04.4 LTS 中的 vncserver bash 脚本错误

转载 作者:太空宇宙 更新时间:2023-11-04 05:23:30 24 4
gpt4 key购买 nike

我使用 Ubuntu 14.04.4 LTS 并安装了 vnc4server。启动 vncdesktops 的基本脚本位于/etc/init.d/vncserver 下,它是一个 bash 脚本。这对于/etc/vncserver/vncservers.conf 中指定的所有用户及其参数都适用。但是,当用户使用 csh 而不是 bash 时,vncserver 命令将不起作用,因为 vncserver 脚本中存在语法错误。错误发生在我在此处显示的 start() 函数中。

start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}

当我发出命令“sudo service vncserver restart”时,vncserver 脚本会运行,并为使用 csh 的用户提供此错误。

Starting VNC server: 8:test1 [: No match.

用户“test1”正在使用 csh,其显示编号为 8。我可以看到此错误来自该行

su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"

我明白它在做什么,但我不知道为什么括号条件会给我这个错误,并且仅适用于使用 csh 的用户。谁能给我一个线索吗?

最佳答案

我不知 Prop 体原因,但我发现我的/bin/csh 链接如下。

/bin/csh -> /etc/alternatives/csh  

所以我安装了 tcsh (apt-get install tcsh) 并制作了这样的链接。

/bin/csh -> /bin/tcsh  

那么问题就解决了!su 命令和 -c 选项执行的命令正在 su'ed 用户的 shell 中处理,该 shell 是/etc/alternatives/csh ,可能无法处理 [ -f ] 条件。我猜想/etc/alternatives/csh 是一种默认的 csh,当没有真正成熟的 csh(如 tcsh)时链接到。

关于linux - ubuntu 14.04.4 LTS 中的 vncserver bash 脚本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37213127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com