1 Reply Latest reply on Jul 6, 2012 5:44 PM by Charles Wells III

    Using Python with RHEL 5 and JBoss EAP 5.1

    Charles Wells III Newbie

      I've attempted to write a small script that when ran successfully should return a menu of JBoss server instances. Below is the script.

       

      import os

      import sys

       

      # Create Parent Menu

      def parent_menu():

          num = 1

          menuItems = {}

       

          files = os.listdir('/dsto/sw/dev/webapps/jbossEAP5.1/applications/jbossas/server')

          os.system("clear")

       

          print "Server Instances"

          print "****************"

          for file in files:

              print "%d. %-3s" % (num, file)

              menuItems[num] = file

              num = num + 1

       

          try:

              print ""

              selection = raw_input("Choose Server Instance: ")

              print ""

              print "You selected %s" % menuItems[int(selection)]

              choice = menuItems[int(selection)]

              return choice

          except KeyError, ValueError:

              print "%s is not a menu option!" % selection

              exit

       

      if __name__=="main":

          parent_menu()

          print "Main Executed"

      else:

          print "Main not executed"

       

      The issue I am having is that when run flow falls to the 'else:' statement in the main mod and dies. My testing indicates that it doesn't like if __name__=="main":

      If I take this script and place it on a Unix AIX machine it runs fine without issue.

       

      Has anyone ever come across an instance where the main module doesn't process as expected that's similar to what I am seeing?