I am new to perl, and I am rewriting a bash script that needs to be in perl. The previous bash script would check to see if a specific package on linux was in an unconfigured state and would delete the package and then reinstall the package.
#!/bin/bash
if [[ $(dpkg -l | grep libc-bin | grep iF) || $(dpkg -l | grep libc-dev-bin | grep iU) ]] ; then
echo "do something"
fi
And this need to be translated to perl. I started to see if I could use system calls and store them as variables and then just run an if statement of these multiple variables. This did not seem to work.
#!/usr/bin/perl
my $libcUnconfigured = system("dpkg -l | grep libc-bin | grep iF");
my $libcDevUnconfigured = system("dpkg -l | grep libc-dev-bin | grep iF");
if ( $libcUnconfigured || $libcDevUnconfigured ){
print "Do something";
}
Aucun commentaire:
Enregistrer un commentaire