How to ensure yum installation in shell script?

I have a shell script that checks for an internet connection (by pinging google) and then calls

yum install packageA packageB --assumeyes

How can I confirm that the packages have been installed (or already installed)? Am I making another yum call and analyzing the output (I suppose it is very difficult if the system is in a different language)?

+5
source share
3 answers

Based on this random message , it looks like yum is returning an error code to the shell. You can verify this by running the command and then immediately (like the following command):

echo $?

. 0, - . , , .:)

+5

, , , , , , :

, PACKAGES , , :

  • yum -y install $PACKAGES ( , script, -y, ).
  • , .
  • rpm --query --queryformat "" $PACKAGES, package <name> is not installed .
  • , , , , , .. 0 , .

, PACKAGES , yum , , yum URL-, Provides:.

+10

Using ping google.com does not guarantee that the yum repository you are trying to connect is accessible

Command to check if a package is installed: -

yum list installed PACKAGE_NAME
+6
source

All Articles