How-to verify if my package installed successfully
Can you please let me know how can i verify /check inside the script if the below to package installation commands are successful or if they failed for any reasons?
1. pkgadd -a $INSTP/install/dadmin -d $INSTP/install/apachesrv.pkg
2. pkgadd -a $INSTP/install/dadmin -d $INSTP/install/apachesrv.pkg>/tmp/install.log
You do it with pkgadd the same way you do it with every other command... You check the man page for the utility in question to see what exit code it produces when it succeeds. You run the command. You check the exit code after the command completes. And, if the exit code matches the exit code listed on the man page for that utility for successful completion, then you know the command succeeded; otherwise, it failed.
As with about 99.44% of utilities, pkgadd exits with exit code 0 if it completed successfully. Of course, the way you check the exit status varies depending on the shell you use (and you haven't bothered to tell us what shell you use). If we make the wild assumption that you're using sh, ksh, bash, or /usr/xpg4/bin/sh (or another shell based on Bourne shell syntax), you could try something like:
Wouldn't pkgadd -a $INSTP/install/dadmin -d $INSTP/install/apachesrv.pkg>/tmp/install.log always succeed even if pkgadd fails becoz of the redirection >/tmp/install.log being successful ?
Wouldn't pkgadd -a $INSTP/install/dadmin -d $INSTP/install/apachesrv.pkg>/tmp/install.log always succeed even if pkgadd fails becoz of the redirection >/tmp/install.log being successful ?
If this would be the case UNIX would be VERY wrong - and, in fact, it isn't. You probably confuse that with a pipe (cmd1 | cmd2 | cmd3) where you get only one exit code for all the commands.
@Don:
Quote:
As with about 99.44% of utilities,
Its 99.43978210653% +/- one epsilon - roundabout. ;-))
Wouldn't pkgadd -a $INSTP/install/dadmin -d $INSTP/install/apachesrv.pkg>/tmp/install.log always succeed even if pkgadd fails becoz of the redirection >/tmp/install.log being successful ?
Good question. No, because a redirection is not a separate command. In the case of a simple command it is considered part of the simple command..
Quote:
A "simple command" is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control operator.
So, #!/bin/bash -e will exit the script even if pkgadd fails in the below statement ?
Yes.
And, you know that you can easily test this out with the script:
which if you save this in a file, make it executable, and run it will print before, create an empty file named junk, and exit without printing after.
This User Gave Thanks to Don Cragun For This Post:
Hello,
i have installed a package by using the command
sudo rpm -i filepackage.rpm
package filepackage is already installed
when i try to remove it, i get an error saying "is not installed":
sudo rpm -e filepackage.rpm
error: package filepackage is not installed
How can... (4 Replies)
Hi,
What is the necessary package that needs to be installed for using pam_mkhomedir.so in pam.conf file?
And from where can i get that file?
Is that package already shipped with Solaris 10?
Because when i use that file i am getting "open_module: stat(/usr/lib/security/pam_mkhomedir.so)... (1 Reply)
Hi gurus, how to (just) download already installed package ?
I tried
sudo apt-get -d install putty
but gives me
Reading package lists... Done
Building dependency tree
Reading state information... Done
putty is already the newest version.
0 upgraded, 0 newly installed, 0 to... (7 Replies)
I develop a unix program in HPUX
I want to package my program
to install on HPUX in some dierctory folder
like /user/local/sbin/xxx
and preinstall some software before install my program
package like xxx.depot
how can i do it, have any tools like use setupfactory tools in windows
... (4 Replies)
i want to write shell script that exit by displaying error if sqlplus is not installed.
The platform is oracle10g on solaris sparc.
I tried the which sqlplus command, but it returns errorcode 0 even sqlplus is not installed.
Kindly help? (3 Replies)
Hi - Basic question from newbie
I need to find out how to verify hardware installed on HPUX server. Mid-range server - as in i need to prove to customer that a specific cpu is installed, so much memory is installed, etc.
PLEASE HELP.
TA (16 Replies)
Hi - Basic question from newbie
I need to find out how to verify hardware installed on HPUX server. Mid-range server - as in i need to prove to customer that a specific cpu is installed, so much memory is installed, etc.
PLEASE HELP.
TA (1 Reply)
Hello There,
Aftar all i successfully installed Solaris 8 on my Primary Slave 2nd Hard disk.
Here what i did.
I kept my first hard disk (Windows Me) on primary Master and put my new 2nd hard disk on Primary Slave, CDROM is on Secondary slave.
When i install solaris8 it ask me two... (0 Replies)