乌班图18.04
我想检查,当用户登录时,他的共享点是否已安装。如果没有,它会提示用户是否要安装它。如果是,则执行 mount 命令,这将提示用户输入密码。
工作正常,但Failed to query password: Permission denied
出现错误消息,当脚本自行运行时,情况并非如此。
我怎样才能抑制它?
Last login: Fri Jan 25 10:59:55 2019 from xxx
Your NAS volume "/data/lambda/nas" is not mounted.
Do you want to mount it (y/n)? y
Failed to query password: Permission denied
Password for lambda@//10.40.40.13/s-dept/lambda:
这是我的脚本
# shellcheck shell=sh
exec 3<&0
grep $USER /etc/fstab | cut -f 2 | while read -r line ; do
if ! grep -qs $line /proc/mounts; then
echo "Your NAS volume \"$line\" is not mounted."
read -u 3 -p 'Do you want to mount it (y/n)? ' -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
mount $line
fi
fi
done
exec 3<&-
编辑:根据要求,这是/etc/fstab
一行
//10.40.40.13/s-dept/lambda /data/lambda/nas cifs noauto,users,username=lambda 0 0