Domanda

I've recently done a script that reconfigures all packages on a Debian Stable (7.3) system. I'm using the command

    dpkg-reconfigure -pcritical -a --force

Everything worked fine, but today I made some changes to the code (I don't think they are related) and now I'm getting this error:

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.

There are thousands of lines full of similar lines (these are the last ones). The system is running in runlevel 1 - single-user - and as user root. And another interesting thing is that dpkg exit code is still 0.

Thank you for your help in advance.

EDIT: here's the script

#!/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 exists\n"
else
    printf "$TARGET doesn't exist!\n"
    exit
fi
if [ -x $PATH ] # Pass 2 - checking execution permissions
then
    printf "$TARGET is executable\n"
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 succeeded\n"
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 succeeded\n"
else printf "Reconfiguration failed\n"
exit $DPKG_EXIT
fi
exit
È stato utile?

Soluzione

Well, sorry for the question as it was absolutely my mistake. Thank you for all those who helped me recognize the bug.

The script didn't work as I accidentally used $PATH as a name for one of my custom variables. It reset the real $PATH and prevented dpkg execute correctly. Now I corrected it to $TARGET_PATH and everything works fine. Once again, sorry for being so careless.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top