HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to trap exit signal by swlist or swinstall com...
Operating System - HP-UX
1833873
Members
2149
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2008 08:37 PM
09-03-2008 08:37 PM
How to trap exit signal by swlist or swinstall command
Hi All,
I need a little help. I have written a shell script which validates whether a particular software is present in a given number of depot files. Now whenever I execute the swlist command in the shell script, and if it finds that the software is not present in the software depot, it exits the script without executing the loop in the script. Please find the script as below :
#!/usr/bin/sh -e
set -x
set -v
BUNDLE="/home/sutapa/doclist"
LOGFILE="/home/sutapa/logfile"
DEPOT="/var/depot/VSM"
if [ ! -f $BUNDLE ]
then
echo "No bundles to install:create the bundle file" ; exit 0 ;
fi
if [ -f $LOGFILE ]
then
rm -rf $LOGFILE
fi
while read line
do
for VAR in $DEPOT/*.depot
do
swlist -s $VAR $line
a=`echo $?`
if [ $a -eq 0 ]
then
swinstall -s $VAR $line
echo "BUNDLE:$line" >> $LOGFILE
echo "DEPOT:$VAR" >> $LOGFILE
fi
done
done < $BUNDLE
Please let me know.
I need a little help. I have written a shell script which validates whether a particular software is present in a given number of depot files. Now whenever I execute the swlist command in the shell script, and if it finds that the software is not present in the software depot, it exits the script without executing the loop in the script. Please find the script as below :
#!/usr/bin/sh -e
set -x
set -v
BUNDLE="/home/sutapa/doclist"
LOGFILE="/home/sutapa/logfile"
DEPOT="/var/depot/VSM"
if [ ! -f $BUNDLE ]
then
echo "No bundles to install:create the bundle file" ; exit 0 ;
fi
if [ -f $LOGFILE ]
then
rm -rf $LOGFILE
fi
while read line
do
for VAR in $DEPOT/*.depot
do
swlist -s $VAR $line
a=`echo $?`
if [ $a -eq 0 ]
then
swinstall -s $VAR $line
echo "BUNDLE:$line" >> $LOGFILE
echo "DEPOT:$VAR" >> $LOGFILE
fi
done
done < $BUNDLE
Please let me know.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2008 09:11 PM
09-03-2008 09:11 PM
Re: How to trap exit signal by swlist or swinstall command
This behaviour is a result of the '-e' flag given to the shell.
From 'man ksh',
------------------------------------------------
-e If the shell is non-interactive and if a
command fails, execute the ERR trap, if set,
and exit immediately. This mode is disabled
while reading profiles.
------------------------------------------------
Removing this flag should continue the execution of the script, even when swlist fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2008 10:08 PM
09-03-2008 10:08 PM
Re: How to trap exit signal by swlist or swinstall command
Thanks a lot it is working now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2008 10:19 PM
09-03-2008 10:19 PM
Re: How to trap exit signal by swlist or swinstall command
a=`echo $?`
The proper way to do this is just: a=$?
If you don't need the value except right after, you can use:
if [ $? -eq 0 ]; then
The proper way to do this is just: a=$?
If you don't need the value except right after, you can use:
if [ $? -eq 0 ]; then
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP