我最近完成了一个脚本,该脚本重新配置了debian stable(7.3)系统上的所有软件包。我正在使用命令
dpkg-reconfigure -pcritical -a --force
一切都很好,但是今天我对代码进行了一些更改(我认为它们没有关系),现在我遇到了这个错误:
Can't exec "dpkg-query": Not a directory at /usr/sbin/dpkg-reconfigure line 98.
Can't exec "dpkg": Not a directory at /usr/sbin/dpkg-reconfigure line 82.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 83.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 84.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 85.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 86.
Can't exec "dpkg-query": Not a directory at /usr/sbin/dpkg-reconfigure line 98.
Can't exec "dpkg": Not a directory at /usr/sbin/dpkg-reconfigure line 82.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 83.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 84.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 85.
Use of uninitialized value $_ in pattern match (m//) at /usr/sbin/dpkg-reconfigure line 86.
Can't exec "dpkg-query": Not a directory at /usr/sbin/dpkg-reconfigure line 98.
Can't exec "dpkg-query": Not a directory at /usr/sbin/dpkg-reconfigure line 202.
readline() on closed filehandle QUERY at /usr/sbin/dpkg-reconfigure line 204.
有成千上万的线充满类似的线(这是最后一条线)。该系统以runlevel 1-单用户的形式运行,作为用户根。另一个有趣的是,DPKG退出代码仍然是0。
感谢您提前的帮助。
编辑:这是脚本
#!/bin/bash
DPKG_RECONFIG_PATH=/usr/sbin/dpkg-reconfigure
# Function for checking critical executables (exits on error)
chk_crit ()
{
TARGET=$1
PATH=$2
if [ -e $PATH ] # Pass 1 - checking existence
then printf "$TARGET existsn"
else
printf "$TARGET doesn't exist!n"
exit
fi
if [ -x $PATH ] # Pass 2 - checking execution permissions
then
printf "$TARGET is executablen"
else
printf "$TARGET is not executable, attempting chmod!n"
chmod 755 $TARGET_PATH
CHMOD_EXIT=$?
if [ $CHMOD_EXIT = 0 ] # Checking if chmod has succeeded
then
printf "chmod succeededn"
else
printf "chmod failed, $TARGET is unusable!n"
exit
fi
fi
}
chk_crit dpkg-reconfigure $DPKG_RECONFIG_PATH
# Reconfiguring all packages, only asking critical questions
$DPKG_RECONFIG_PATH -pcritical -a --force
DPKG_EXIT=$?
if [ $DPKG_EXIT = 0 ]
then printf "Reconfiguration succeededn"
else printf "Reconfiguration failedn"
exit $DPKG_EXIT
fi
exit
,对不起,因为这绝对是我的错误。谢谢您所有帮助我认识该错误的人。
脚本不起作用,因为我意外使用$PATH
作为我的自定义变量之一的名称。它重置实际$PATH
并防止DPKG正确执行。现在,我将其更正为$TARGET_PATH
,一切正常。再次,对不起。