Hi all, Part of my script is to check for pre-requisite rpms to be installed. If its installed, I just display the rpm version as in rpm database, otherwise I output a message saying: ' rpm is not installed' and collect the rpm name in a list (notInstalled). At the end if the len(notInstalled) is greater than 0 then I display them all asking it to be installed and exit the program. My Script is below: ------- #!/usr/bin/env python import os import sys
notInstalled = [] def checkForRpm(rpmname): ''' Check for the presence of the RPM. ''' cin,cout,cerr = os.popen3('rpm -q ' + rpmname) output = cout.read() global notInstalled if len(output) <= 0: print rpmname + ' not installed.' notInstalled.append(rpmname) else: print output def preReqCheckRpms(): ''' Check for the required RPMS ''' listOfRpms = ['firefox','senthil','binutils','gcc','cpp','glibc-devel','glibc-headers','glibc-kernheaders','compat-db','compat-gcc','compat-gcc-c++','compat-libstdc++','compat-libstdc++-devel','gnome-libs','openmotif21','setarch'] for eachRpm in listOfRpms: checkForRpm(eachRpm) global notInstalled if len(notInstalled) > 0: print 'The following RPMS are not installed:' for eachRpm in notInstalled: print eachRpm print 'Please install them for the installation to continue.' sys.exit(-1) def main(): preReqCheckRpms() if __name__ == '__main__': main() ---- * This is NOT Working. * notInstalled.append(rpmname) is not taking effect in checkForRpm(rpmname) * I dont know how to communicate the notInstalled list to preReqCheckRpms. -- Senthil -- http://mail.python.org/mailman/listinfo/python-list