[kwlug-disc] BASH scripting - dpkg or variable issue?

Ronald Barnes ron at ronaldbarnes.ca
Mon Jun 5 17:57:05 EDT 2023


Charles M wrote on 2023-06-05 14:00:

> Hi all, I'm running into an issue where a BASH script is giving me
> the following error:
> 
> dpkg-deb: error: --extract needs a target directory. Perhaps you
> should be using dpkg --install ?
> 
> The error occurs after the following two lines in the script:
> 
> apt-get download shim.signed dpkg -x $SHIMFILE shim
> 
> SHIMFILE is defined at the top of the script as:
> 
> SHIMFILE=$(ls | grep "shim.signed")
> 
> If I echo $SHIMFILE after the script has ended it shows:
> 
> shim-signed_1.40.9+15.7-0ubuntu1_amd64.deb
> 
> If I type the commands in to the terminal everything works... but it 
> doesn't if I use the script... what am I missing?

Could it be a permissions issue?

 From the dpkg-deb man page:

> directory (but not its parents) will be created if necessary, and
> its permissions modified to match the contents of the package.

So, if the script is running with a user and extract target that do not 
have permissions to create the target directory, that's causing the failure?


Of course, your final sentence seems to indicate otherwise, but I 
thought I'd throw this out there...


rb




More information about the kwlug-disc mailing list