This can be modified to suit your needs if you use SUMA. Hopefully someone may find it useful.
Code:
#!/usr/bin/ksh93
Runfile=/tmp/suma.run
CMD="/usr/suma/bin/suma -x "
ECHO=/usr/bin/echo
CHMOD="/usr/bin/chmod 700"
set -A FS $(df -m | grep simages | grep -v "\-00" | awk '{print $7}')
set -A RQNAME $(echo ${FS[@]##*/})
set -A RQLEVEL $(echo ${RQNAME[@]})
set -A FILTERML $(echo ${RQNAME[@]})
set -A ACTION $(echo "Preview" "Download" "Clean")
RQTYPE="TL Security Latest APAR PTF SP CSP"
FILTERDIR=$(df -m | grep simages | awk '{print $7}')
DLTARGET=
numFS=${#FS[@]}
c=0 ; p=0
while (( c < numFS ))
do
FSlen=${#RQNAME[c]}
if [[ ${FSlen} -eq 7 ]] ; then
RQNAME[p]=${RQNAME[c]}
elif [[ ${FSlen} -eq 13 ]]; then
x=${RQNAME[p]##*_}
if [[ ${x} = "SP" ]]; then
SP[p]=${RQNAME[c]}
elif [[ ${x} = "TL" ]]; then
TL[p]=${RQNAME[c]}
fi
elif [[ ${FSlen} -eq 14 ]]; then
x=${RQNAME[p]##*_}
if [[ ${x} = "CSP" ]]; then
CSP[p]=${RQNAME[c]}
fi
fi
((p+=1))
((c+=1))
done
subClear() {
clear
}
Menu() {
set -A action $(echo ${ACTION[@]})
set -A rqtype $(echo ${RQTYPE[@]})
num_action=${#action[@]}
num_rqtype=${#rqtype[@]}
subClear
tput cup 0 0; print "SUMA Main Menu"
tput cup 5 0; print "Enter download directory; Return for the default (/nim/lpp/temp/fileset); or Quit to exit: \c" ; read DLTarget
case $DLTarget in
'' ) DLTarget="/nim/lpp/temp/fileset" ;;
Q|q|Quit|quit|QUIT ) exit 0 ;;
* )
if [[ ! -d ${DLTarget} ]] ; then
subClear
Menu
fi
;;
esac
tput cup 7 0; PS3='Select action: '
select Action in ${action[@]} Quit
do
Select=$Action
subSelectCheck
case $Action in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Action[@]} ) Action=$Action ;;
esac
break
done
PS3='Select type (RqType): '
select Rqtype in ${rqtype[@]} Quit
do
Select=$Rqtype
subSelectCheck
break
done
case $Rqtype in
TL) subML ;;
Security) subSecurity ;;
Latest) subLatest ;;
APAR) subAPAR ;;
PTF) subPTF ;;
SP) subSP ;;
CSP) subCSP ;;
Quit) exit 0 ;;
*) ;;
esac
}
subSelectCheck() {
if [[ ! -n $Select ]] ; then
continue
else
return
fi
}
subML() {
set -A rqname $(echo ${RQNAME[@]})
num_rqname=${#rqname[@]}
l=0 ; e=0
while (( l < num_rqname ))
do
xx=${rqname[l]}
xxLen=${#xx}
xxPrefix=${xx:0:4}
((xxSuffixLen=xxLen-7))
xxSuffix=${xx:8:xxSuffixLen}
xxMaint=${xx:5:2}
if [[ ${xxSuffixLen} -eq 0 ]] ; then
xRqName[e]=${xx}
fi
((e+=1))
((l+=1))
done
subClear
tput cup 0 0; print "Maintenance Level submenu"
tput cup 5 0; PS3='Select Maintenance Level (RqName): '
select Rqname in ${xRqName[@]} Quit
do
Select=$Rqname
subSelectCheck
case $Rqname in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Rqname} ) RqName=$Rqname ;;
esac
break
done
RqnameLen=${#Rqname}
RqnamePrefix=${Rqname:0:4}
((RqnameSuffixLen=RqnameLen-7))
RqnameSuffix=${Rqname:8:RqnameSuffixLen}
RqnameMaint=${Rqname:5:2}
set -A filterml $(echo ${FILTERML[@]})
num_filterml=${#filterml[@]}
PS3='Select Filter Maintenance Level (FilterML): '
subFilterML
subFilterMlCheck
select Filterml in ${zfilterml[@]} Quit None
do
Select=$Filterml
subSelectCheck
case $Filterml in
None ) FilterML=
;;
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterml} ) FilterML=$Filterml ;;
esac
break
done
FiltermlLen=${#Filterml}
FiltermlPrefix=${Filterml:0:4}
((FiltermlSuffixLen=FiltermlLen-7))
FiltermlSuffix=${Filterml:8:FiltermlSuffixLen}
FiltermlMaint=${Filterml:5:2}
}
subFilterML() {
a=0 ; t=0
set -A FilterSubSet $(echo ${filterml[@]})
numFilterSubSet=${#FilterSubSet[@]}
while (( a < numFilterSubSet ))
do
FilterSubSetPrefix=${FilterSubSet[a]%%-*}
if [[ ${FilterSubSetPrefix} = ${RqnamePrefix} ]] ; then
pfilterml[t]=${FilterSubSet[a]}
fi
((t+=1))
((a+=1))
done
return
}
subFilterMlCheck() {
s=0 ; v=0
set -A FilterSubSet $(echo ${pfilterml[@]})
numFilterSubSet=${#FilterSubSet[@]}
while (( s < numFilterSubSet ))
do
FilterSubSetLen=${#FilterSubSet[s]}
((FilterSubSetSuffixLen=FilterSubSetLen-7))
FilterSubSetPrefix=${FilterSubSet[s]:0:4}
FilterSubSetSuffix=${FilterSubSet[s]:8:FilterSubSetSuffixLen}
FilterSubSetMaint=${FilterSubSet[s]:5:2}
if [[ ${FilterSubSetMaint} -lt ${RqnameMaint} && ${FilterSubSetSuffixLen} -eq 0 ]] ; then
zfilterml[v]=${FilterSubSet[s]}
fi
((v+=1))
((s+=1))
done
return
}
subSecurity() {
subClear
tput cup 0 0; print "Security submenu"
set -A filterml $(echo ${FILTERML[@]})
num_filterml=${#filterml[@]}
n=0 ; q=0
while (( n < num_filterml ))
do
secfilterml=${filterml[n]}
secfiltermlLen=${#secfilterml}
secfiltermlPrefix=${secfilterml:0:4}
((secfiltermlSuffixLen=secfiltermlLen-7))
secfiltermlSuffix=${secfilterml:8:secfiltermlSuffixLen}
if [[ ${secfiltermlSuffixLen} -eq 0 ]] ; then
secFilterML[q]=${secfilterml}
fi
((q+=1))
((n+=1))
done
tput cup 6 0; PS3='Select Filter Maintenance Level (FilterML): '
select Filterml in ${secFilterML[@]} Quit
do
Select=$Filterml
subSelectCheck
case $Filterml in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterml} ) FilterML=$Filterml ;;
esac
break
done
FiltermlLen=${#Filterml}
FiltermlPrefix=${Filterml:0:4}
FiltermlMaint=${Filterml:5:2}
((FiltermlSuffixLen=FiltermlLen-7))
FiltermlSuffix=${Filterml:8:FiltermlSuffixLen}
subFilterSecurity
}
subFilterSecurity() {
set -A filtersec $(echo ${FILTERDIR[@]})
num_filtersec=${#filtersec[@]}
w=0 ; m=0
while (( w < num_filtersec ))
do
FilterDirPath=${filtersec[w]}
FilterDirVR=${filtersec[w]##*/}
FilterDirVRLen=${#FilterDirVR}
FilterDirPrefix=${FilterDirVR:0:4}
FilterDirMaint=${FilterDirVR:5:2}
((FilterDirSuffixLen=FilterDirVRLen-7))
FilterDirSuffix=${FilterDirVR:8:FilterDirSuffixLen}
if [[ ${FilterDirPrefix} -eq ${FiltermlPrefix} ]] ; then
ufilterml[m]=${FilterDirVR}
fi
((m+=1))
((w+=1))
done
subSecurityFilterDir
}
subSecurityFilterDir() {
g=0 ; h=0
set -A FilterSec $(echo ${ufilterml[@]})
num_FilterSec=${#FilterSec[@]}
while (( g < num_FilterSec ))
do
FilterSecLen=${#FilterSec[g]}
FilterSecPrefix=${FilterSec[g]:0:4}
FilterSecMaint=${FilterSec[g]:5:2}
((FilterSecSuffixLen=FilterSecLen-7))
FilterSecSuffix=${FilterSec[g]:8:FilterSecSuffixLen}
if [[ ${FilterSecMaint} -lt ${FiltermlMaint} ]] ; then
tfilterml[h]=${FilterSec[g]}
elif [[ ${FilterSecMaint} -eq ${FiltermlMaint} && ${FilterSecSuffix} -lt ${FiltermlSuffix} ]] ; then
tfilterml[h]=${FilterSec[g]}
elif [[ ${FilterSecMaint} -eq ${FiltermlMaint} && ${FilterSecSuffix} != CSP && ${FiltermlSuffix} = CSP ]] ; then
tfilterml[h]=${FilterSec[g]}
fi
((h+=1))
((g+=1))
done
DIRPATH=/nim/install/simages/
y=0
while (( y < ${#tfilterml[@]} ))
do
cfilterml[y]=${DIRPATH}${tfilterml[y]}
((y+=1))
done
PS3='Select directory to filter against (FilterDir): '
select FilterDir in ${cfilterml[@]} Quit
do
Select=$FilterDir
subSelectCheck
case $FilterDir in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${FilterDir} ) FilterDir=${FilterDir} ;;
esac
break
done
}
subFilterDir() {
set -A filterdir $(echo ${FILTERDIR[@]})
num_filterdir=${#filterdir[@]}
PS3='Select Filter Directory (FilterDir): '
select Filterdir in ${filterdir[@]} Quit
do
Select=$Filterdir
subSelectCheck
case $Filterdir in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterdir} ) FilterDir=$Filterdir ;;
esac
break
done
}
subLatest() {
subClear
tput cup 0 0; print "Latest submenu"
set -A filterml $(echo ${FILTERML[@]})
num_filterml=${#filterml[@]}
w=0 ; i=0
while (( i < num_filterml ))
do
LatestFilterMl=${filterml[i]}
LatestFilterMlLen=${#LatestFilterMl}
LatestFilterMlPrefix=${LatestFilterMl:0:4}
((LatestFilterMlSuffixLen=LatestFilterMlLen-7))
LatestFilterMlSuffix=${LatestFilterMl:8:LatestFilterMlSuffixLen}
LatestFilterMlMaint=${LatestFilterMl:5:2}
if [[ ${LatestFilterMlSuffixLen} -eq 0 ]] ; then
Lfilterml[w]=${LatestFilterMl}
fi
((w+=1))
((i+=1))
done
tput cup 6 0; PS3='Select Filter Maintenance Level (FilterML): '
select Filterml in ${Lfilterml[@]} Quit
do
Select=$Filterml
subSelectCheck
case $Filterml in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterml} ) FilterML=$Filterml ;;\
esac
break
done
FiltermlLen=${#Filterml}
FiltermlPrefix=${Filterml:0:4}
((FiltermlSuffixLen=FiltermlLen-7))
FiltermlSuffix=${Filterml:8:FiltermlSuffixLen}
FiltermlMaint=${Filterml:5:2}
subFilterLatest
subLatestFilterDir
}
subFilterLatest() {
set -A filterlatest $(echo ${FILTERDIR[@]})
num_filterlatest=${#filterlatest[@]}
w=0 ; m=0
while (( w < num_filterlatest ))
do
FilterDirPath=${filterlatest[w]}
FilterDirVR=${filterlatest[w]##*/}
FilterDirVRLen=${#FilterDirVR}
FilterDirPrefix=${FilterDirVR:0:4}
FilterDirMaint=${FilterDirVR:5:2}
((FilterDirSuffixLen=FilterDirVRLen-7))
FilterDirSuffix=${FilterDirVR:8:FilterDirSuffixLen}
if [[ ${FilterDirPrefix} -eq ${FiltermlPrefix} ]] ; then
ufilterml[m]=${FilterDirVR}
fi
((m+=1))
((w+=1))
done
return
}
subLatestFilterDir() {
g=0 ; h=0
set -A FilterLatest $(echo ${ufilterml[@]})
num_FilterLatest=${#FilterLatest[@]}
while (( g < num_FilterLatest ))
do
FilterLatestLen=${#FilterLatest[g]}
FilterLatestPrefix=${FilterLatest[g]:0:4}
FilterLatestMaint=${FilterLatest[g]:5:2}
((FilterLatestSuffixLen=FilterLatestLen-7))
FilterLatestSuffix=${FilterLatest[g]:8:FilterLatestSuffixLen}
if [[ ${FilterLatestMaint} -lt ${FiltermlMaint} ]] ; then
tfilterml[h]=${FilterLatest[g]}
elif [[ ${FilterLatestMaint} -eq ${FiltermlMaint} && ${FilterLatestSuffix} -lt ${FiltermlSuffix} ]] ; then
tfilterml[h]=${FilterLatest[g]}
elif [[ ${FilterLatestMaint} -eq ${FiltermlMaint} && ${FilterLatestSuffix} != CSP && ${FiltermlSuffix} = CSP ]] ; then
tfilterml[h]=${FilterLatest[g]}
fi
((h+=1))
((g+=1))
done
DIRPATH=/nim/install/simages/
y=0
while (( y < ${#tfilterml[@]} ))
do
cfilterml[y]=${DIRPATH}${tfilterml[y]}
((y+=1))
done
PS3='Select directory to filter against (FilterDir): '
select FilterDir in ${cfilterml[@]} Quit
do
Select=$FilterDir
subSelectCheck
case $FilterDir in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${FilterDir} ) FilterDir=${FilterDir} ;;
esac
break
done
}
subAPAR() {
subClear
tput cup 0 0; print "APAR submenu"
tput cup 5 0; print "Enter APAR (e.g., IY12345): \c" ; read apar
typeset -u Uapar=$apar
subAPARcheck
RqName=$Uapar
tput cup 5 0; print " "
tput cup 2 0 ; print "APAR for download is ${Uapar}"
set -A afilterlevel $(echo ${RQLEVEL[@]})
num_afilterlevel=${afilterlevel[@]}
s=0 ; v=0
set -A FilterAPAR $(echo ${afilterlevel[@]})
num_FilterAPAR=${#FilterAPAR[@]}
while (( s < num_FilterAPAR ))
do
FilterAPARs=${FilterAPAR[s]}
FilterAPARsLen=${#FilterAPARs}
FilterAPARsPrefix=${FilterAPARs:0:4}
FilterAPARsMaint=${FilterAPARs:5:2}
((FilterAPARsSuffixLen=FilterAPARsLen-7))
FilterAPARsSuffix=${FilterAPARs:8:FilterAPARsSuffixLen}
if [[ ${FilterAPARsSuffixLen} -eq 0 ]] ; then
vfilterlevel[v]=${FilterAPARs}
fi
((v+=1))
((s+=1))
done
tput cup 6 0; PS3='Select Level (RqLevel): '
select Rqlevel in ${vfilterlevel[@]} Quit
do
Select=$Rqlevel
subSelectCheck
case $Rqlevel in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Rqlevel} ) RqLevel=$Rqlevel ;;
esac
break
done
}
subAPARcheck() {
aparLen=${#Uapar}
aparPrefix=${Uapar:0:2}
aparSuffix=${Uapar:2:5}
if [[ ${aparPrefix} != [a-zA-Z]* ]] ; then
subAPAR
elif [[ ${aparSuffix} != [0-9]* ]] ; then
subAPAR
elif [[ ${aparLen} -ne 7 ]] ; then
subAPAR
else
return
fi
}
subPTF() {
subClear
tput cup 0 0; print "PTF submenu"
tput cup 5 0; print "Enter PTF (e.g., U123456): \c" ; read ptf
typeset -u Uptf=$ptf
subPTFcheck
RqName=$Uptf
break
}
subPTFcheck() {
ptfLen=${#Uptf}
ptfPrefix=${Uptf:0:1}
ptfSuffix=${Uptf:1:6}
if [[ ${ptfPrefix} != [a-zA-Z]* ]] ; then
subPTF
elif [[ ${ptfSuffix} != [0-9]* ]] ; then
subPTF
elif [[ ${ptfLen} -ne 7 ]] ; then
subPTF
else
return
fi
}
subSP() {
subClear
tput cup 0 0; print "Service Pack submenu"
set -A sp $(echo ${SP[@]%%_*})
num_sp=${#sp[@]}
tput cup 5 0; PS3='Select Service Pack (RqName): '
select Sp in ${sp[@]} Quit
do
Select=$Sp
subSelectCheck
case $Sp in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Sp} ) SP=$Sp ;;
esac
break
done
set -A filterml $(echo ${FILTERML[@]})
num_filterml=${#filterml[@]}
PS3='Select Filter Maintenance Level (FilterML): '
subFilterSP
select Filterml in ${xfilterml[@]} Quit
do
Select=$Filterml
subSelectCheck
case $Filterml in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterml} ) FilterML=$Filterml ;;
esac
break
done
}
subFilterSP() {
a=0 ; t=0
set -A FilterSubSet $(echo ${filterml[@]})
numFilterSubSet=${#FilterSubSet[@]}
SpLen=${#Sp}
SpPrefix=${Sp:0:4}
SpMaint=${Sp:5:2}
((SpSuffixLen=SpLen-7))
SpSuffix=${Sp:8:SpSuffixLen}
while (( a < numFilterSubSet ))
do
FilterSubSetLen=${#FilterSubSet[a]}
FilterSubSetPrefix=${FilterSubSet[a]:0:4}
((FilterSubSetSuffixLen=FilterSubSetLen-7))
FilterSubSetSuffix=${FilterSubSet[a]:8:FilterSubSetSuffixLen}
FilterSubSetMaint=${FilterSubSet[a]:5:2}
if [[ ${FilterSubSetPrefix} = ${SpPrefix} ]] ; then
if [[ ${FilterSubSetMaint} -lt ${SpMaint} && ${FilterSubSetSuffixLen} -eq 0 ]] ; then
xfilterml[t]=${FilterSubSet[a]}
elif [[ ${FilterSubSetMaint} -eq ${SpMaint} && ${FilterSubSetSuffixLen} -eq 0 ]] ; then
xfilterml[t]=${FilterSubSet[a]}
fi
fi
((t+=1))
((a+=1))
done
return
}
subCSP() {
subClear
tput cup 0 0; print "Concluding Service Pack submenu"
set -A csp $(echo ${CSP[@]})
num_sp=${#csp[@]}
tput cup 5 0; PS3='Select Service Pack (RqName): '
select Csp in ${csp[@]} Quit
do
Select=$Csp
subSelectCheck
case $Csp in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Csp} ) CSP=$Csp ;;
esac
break
done
set -A filterml $(echo ${FILTERML[@]})
num_filterml=${#filterml[@]}
PS3='Select Filter Maintenance Level (FilterML): '
subFilterCSP
select Filterml in ${xfilterml[@]} Quit
do
Select=$Filterml
subSelectCheck
case $Filterml in
Q|q|Quit|quit|QUIT ) exit 0 ;;
${Filterml} ) FilterML=$Filterml ;;
esac
break
done
}
subFilterCSP() {
z=0 ; y=0
set -A FilterSubSet $(echo ${filterml[@]})
numFilterSubSet=${#FilterSubSet[@]}
CspLen=${#Csp}
CspPrefix=${Csp:0:4}
CspMaint=${Csp:5:2}
((CspSuffixLen=CspLen-7))
CspSuffix=${Csp:8:CspSuffixLen}
while (( z < numFilterSubSet ))
do
FilterSubSetLen=${#FilterSubSet[z]}
((FilterSubSetSuffixLen=FilterSubSetLen-7))
FilterSubSetPrefix=${FilterSubSet[z]:0:4}
FilterSubSetSuffix=${FilterSubSet[z]:8:FilterSubSetSuffixLen}
FilterSubSetMaint=${FilterSubSet[z]:5:2}
if [[ ${FilterSubSetPrefix} = ${CspPrefix} ]] ; then
if [[ ${FilterSubSetMaint} -le ${CspMaint} && ${FilterSubSetSuffix} != CSP ]] ; then
xfilterml[y]=${FilterSubSet[z]}
fi
fi
((y+=1))
((z+=1))
done
return
}
subBuildCmd() {
Action=" -a Action=$Action"
case $Rqtype in
TL) DLTarget=" -a DLTarget=$DLTarget"
RqName=" -a RqName=$RqName"
FilterML=" -a FilterML=$FilterML"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName $FilterML"
;;
Security) DLTarget=" -a DLTarget=$DLTarget"
FilterDir=" -a FilterDir=$FilterDir"
FilterML=" -a FilterML=$FilterML"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName $FilterML"
;;
Latest) DLTarget=" -a DLTarget=$DLTarget"
FilterDir=" -a FilterDir=$FilterDir"
FilterML=" -a FilterML=$FilterML"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $FilterDir $FilterML"
;;
APAR) DLTarget=" -a DLTarget=$DLTarget"
RqName=" -a RqName=$RqName"
RqLevel=" -a RqLevel=$RqLevel"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName $RqLevel"
;;
PTF) DLTarget=" -a DLTarget=$DLTarget"
RqName=" -a RqName=$RqName"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName"
;;
SP) DLTarget=" -a DLTarget=$DLTarget"
RqName=" -a RqName=$SP"
FilterML=" -a FilterML=$FilterML"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName $FilterML"
;;
CSP) DLTarget=" -a DLTarget=$DLTarget"
RqName=" -a RqName=$CSP"
FilterML=" -a FilterML=$FilterML"
RqType=" -a RqType=$Rqtype"
RUN="$CMD $Action $DLTarget $RqType $RqName $FilterML"
;;
*) exit 127 ;;
esac
}
trap 'rm -f "$Runfile" >/dev/null 2>&1' 0
trap '' 1 2 3 15
Menu
subBuildCmd
$ECHO $RUN > $Runfile ; $CHMOD $Runfile ; exec $Runfile