Solved

Jython Script to modify listener ports

Posted on 2011-02-15
32
3,134 Views
Last Modified: 2013-12-11
Hi,

I am trying to create a jython script to modify listener ports by taking the properties from a properties file. But some how it is not working and I am not sure whether my approach is correct or not. Can someone please help me? Please find the attachment for the script and properties fille.

Thanks
UpdateLP.py
UpdateLP.txt
0
Comment
Question by:k_satish22
  • 17
  • 14
32 Comments
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 34905688
what do you it;s not working? it fails or you dont see the result after successful execution ?
0
 

Author Comment

by:k_satish22
ID: 34906070
It is failing with errors. I thinking there is some problem with the logic. The script I am using was created to create listener ports. I am trying to modify it to use for modify listener port properties.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34909194
It would help us if you provided the output of a sample execution.

For what are you looking?
- Comments / suggestions about what is failing during the execution of the script?
- Comments / suggestions about programming style?

0
 

Author Comment

by:k_satish22
ID: 34909260
Hello HonorGod,

I need a script to modify the listner port properties in JACL and jython. Both the script  should take input from a properties file.

here is the output of the script ...
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\
Jython_Scripts\createLP.py C:\ACS\Jython_Scripts\createLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SO
AP connector;  The type of process is: UnManagedProcess
WASX7303I: The following options are passed to the scripting environment and are
 available as arguments that are stored in the argv variable: "[C:\ACS\Jython_Sc
ripts\createLP.txt]"

createLP: INFO --- In main function

createLP: INFO --- Loading the properties to Hash Map => START......

createLP: INFO --- Loading the properties to Hash Map => DONE.


createLP: INFO --- Adding property value to servers START......


createLP: ERROR --- Unable to find server server1.Check the logs for more inform
ation.
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\createLP
.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7077E:
 Incomplete config id: need closing parenthesis in ""

Thank you
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34909506
Given the input file attached above, I would expect your script to failing within createPropValues() when it makes this call
updateLP(cellName,nodeName,serverName,cfName,rolesList[0],rolesList[1],rolesList[2],rolesList[3],rolesList[4])

because updateLP() would try to:
server = AdminConfig.getid('/Cell:'+cellName+'/Node:'+nodeName+'/Server:'+serverName)

when cellName, nodeName, and serverName are empty strings, which would mean that the call would be like:

server = AdminConfig.getid('/Cell:/Node:/Server:')

which should result in an error like this:

WASX7015E: Exception running command: "AdminConfig.getid('/Cell:/Node:/Server:')"; exception information:
 com.ibm.ws.scripting.ScriptingException: Invalid object name: /Cell:/Node:/Server:

On the other hand, if your "property file" actually contains valid values for

CellName=
NodeName=
ServerName=

Then, the result of the call to AdminConfig.getid() should be a valid configuration ID.
However, we don't know for certain because the script doesn't display the result of the call.

So, where might it be failing?  Well, since we don't see the message that "should" be generated next (i.e., "nupdateLP: INFO --- Checking to see if Listener port..."), the call that is most likely failing is:

mls = AdminConfig.list('MessageListenerService', server)


0
 

Author Comment

by:k_satish22
ID: 34914552
You are correct I have removed the cell name, node name and server name in the attached properties file. The property file which I am using is having those details.

For so reason when I am using single quote characters wsadmin is throwing the below error so I changed the single quote characters to double quote characters and it worked. I have updated the script with double quote characters.

wsadmin>AdminConfig.getid('Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1')
WASX7015E: Exception running command: "AdminConfig.getid('Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1')"
; exception information:
 com.ibm.ws.scripting.ScriptingException: Invalid object name: Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:serve
r1

Now I  am getting below error when I am executing the script. Please find the attachment for you updated script and properties file.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Update_LP.py C:\ACS\Jython_Scripts\Upd
ate_LP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Update_LP.txt]"

updateLP: INFO --- In main function

updateLP: INFO --- Loading the properties to Hash Map => START......

updateLP: INFO --- Loading the properties to Hash Map => DONE.


updateLP: INFO --- Adding property value to servers START......

WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Update_LP.py"; exception information: com.ibm.bsf.BSFExceptio
n: exception from Jython:
Traceback (innermost last):
  File "<string>", line 130, in ?
  File "<string>", line 123, in main
  File "<string>", line 59, in createPropValues
  File "<string>", line 64, in updateLP
TypeError: __add__ nor __radd__ defined for these operands

Update-LP.py
Update-LP.txt
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34916539
> You are correct I have removed the cell name, node name and server name in the attached properties file. The property file which I am using is having those details.

  This is very reasonable.

> For so reason when I am using single quote characters wsadmin is throwing the below error so I changed the single quote characters to double quote characters and it worked. I have updated the script with double quote characters.

  Jython (and Python) allow either single, or double quotes as string delimiters. The limitations are:

- The same quote character (either single or double) must be used to end the string that was used to start the string.  So, if you start the string with a single quote, then you must end with a single quote.

- If the string needs to include, or contain, the starting/ending quote character, then the place(s) within the string where this character should be positioned, must be "escaped" by having the quote character immediately preceded by a backslash character:

>>> 'Don\'t'
"Don't"

> WASX7015E: Exception running command: ...
> ... Invalid object name:

  The "name" that you specified is invalid because it should start and end with a slash...

AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )

> Traceback (innermost last):
  File "<string>", line 130, in ?
  File "<string>", line 123, in main
  File "<string>", line 59, in createPropValues
  File "<string>", line 64, in updateLP
TypeError: __add__ nor __radd__ defined for these operands

  The way to read this is:

- Line 130 is where the first (outermost) function call occurred.
  When we look at this line, we find that it contains:

130: main()

  Which is no surprise.

- The next function call happened in line 123, which happens to be within the function named main()
  as the stack trace tells us.  This line has:

123:   createPropValues()

- The next function call happened in line 59, which is in createPropValues, and which looks like:

 59:       updateLP(...)

- The last line (i.e., 64) tells us the one in which the error (exception) actually occurred.  This line has:

 64:    server = AdminConfig.getid("/Cell:"+cellName+"/Node:"+nodeName+"/Server:"+serverName)

  What's wrong with this statement?  Well, it all depends upon the values of the variables.
  If cellName, nodeName, and serverName are strings, then the plus sign represents a string concatenation operation.  However, if, for example, the value of cellName is None, we get the following:
wsadmin>"/Cell:" + None
WASX7015E: Exception running command: ""/Cell:" + None"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
TypeError: __add__ nor __radd__ defined for these operands

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34916551
So, you really need to verify your data before you use it.

Does that make sense?
0
 

Author Comment

by:k_satish22
ID: 34918955
Thank you somuch for your help. Yes it make perfect sence.

Now I have resolve few issues with script but now it failing with a message saying Listener port not there on the server. Please find the details below. Can you please fix the logic which I have used in the script?
Requirments of othe script is

1. check whether the ListnerPort is there or not, if it not there exit from the script saying ListnerPort is not there.
2 If ListnerPort is there  update the ListnerPort properties by taking them from  the properties file.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Update_LP.py C:\ACS\Jython_Scripts\Upd
ate_LP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Update_LP.txt]"

updateLP: INFO --- In main function
updateLP: INFO --- Loading the properties to Hash Map => START......
updateLP: INFO --- Loading the properties to Hash Map => DONE.
updateLP: INFO --- Adding property value to servers START......
updateLP: INFO --- Checking to see if Listener port sample is configured on server server1
updateLP: INFO --- Listener port sample Not there on server server1. Skipping Listener port modification.

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34919029
Your description of what you need (now) is much better.  [Thank you!]

Please attach the current version of your script.

Thanks!
0
 

Author Comment

by:k_satish22
ID: 34919274
Please find the attachement
Update-LP.py
Update-LP.txt
0
 

Author Comment

by:k_satish22
ID: 34929180
Hi  HonorGod

I know you are busy. Just want to know the status. Thank you very much for your help.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34931070
I know that it's not complete, but take a look at this...
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          head, tail = line.split( '=', 1 );
          jndi, rest = tail.split( ':', 1 );
          print 'jndi:', jndi;
          print 'rest:', rest;
    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34933286
I don't have any ListenerPorts defined, so I was wondering if you would try the following for me in an  wsadmin command invocation:

I'm trying to find out if we can get the list of defined ListenerPorts scoped by an Application Server

Thanks
wsadmin -conntype none -lang jython -c "print AdminConfig.list( 'ListenerPort', AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' ) )"

Open in new window

Equivalent interactive commands:

---------------------------------------------------------------
s = AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )

print AdminConfig.list( 'ListenerPort', s )
---------------------------------------------------------------

Open in new window

0
 

Author Comment

by:k_satish22
ID: 34933568
wsadmin>s = AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )
wsadmin>print AdminConfig.list( 'ListenerPort', s )
sample(cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#ListenerPort_1297826551343)
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34934647
Excellent.  That helps immensely!

Alright.  This version makes use of that information.

Here's the next question for you:

Given the specified "ListenerPort Name", do you want to modify all of the attributes using the input line?

For example, from your input file, the "ListenerPort Name" should be "sample"
Do you want to change the connectionFactoryJNDIName to what follows, then
the maxSessions, maxRetries, and maxMessages using the (integer) values that follow?

What happens if a value is missing?

Are the values required, or optional?

Thanks for helping me understand.
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          prefix, suffix = line.split( '=', 1 );
          LPname, rest   = suffix.split( ':', 1 );
          print 'LPname:', LPname;
          print 'rest:', rest;
          for LP in AdminConfig.list( 'ListenerPort', server ).splitlines() :
            if LPname == AdminConfig.showAttribute( LP, 'name' ) :
              print AdminConfig.show( LP );

    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:k_satish22
ID: 34935513
It would be good if they are optional. Depending on the requirements we will update the properties file with the required values. If we did not specify a value in the properties files that value should not be changed.

Thank you so much for your help. You Rock...  
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34939787
This "might" work...
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          #-----------------------------------------------------------
          # prefix == 'Property:Value'
          # suffix == ListenerPort Name:JNDI Name,Connection Factory Name,maxsessions,maxretries,maxmessages
          #-----------------------------------------------------------
          prefix, suffix = line.split( '=', 1 );
          LPname, rest   = suffix.split( ':', 1 );
          print 'LPname:', LPname;
          print 'rest:', rest;
          #-----------------------------------------------------------
          # [ 0 ] == destinationJNDIName
          # [ 1 ] == connectionFactoryJNDIName
          # [ 2 ] == maxSessions
          # [ 3 ] == maxRetries
          # [ 4 ] == maxMessages 
          #-----------------------------------------------------------
          values = rest.split( ',' );
          values.extend( [ '' ] * 5 ); # Guarantee sufficient values exist...
          for LP in AdminConfig.list( 'ListenerPort', server ).splitlines() :
            if LPname == AdminConfig.showAttribute( LP, 'name' ) :
              print 'Before:\n' + ( '-' * 50 );
              print AdminConfig.show( LP );
              print '-' * 50;
              #-------------------------------------------------------
              # Use list comprehension to 
              #-------------------------------------------------------
              changes =  [ item for item in [ 'destinationJNDIName'      , values[ 0 ] ],
                                            [ 'connectionFactoryJNDIName', values[ 1 ] ],
                                            [ 'maxSessions'              , values[ 2 ] ],
                                            [ 'maxRetries'               , values[ 3 ] ],
                                            [ 'maxMessages'              , values[ 4 ] ] if item[ 1 ] ] );
              print 'Changes: ' + str( changes );
              AdminConfig.modify( LP, changes );

              print ' After:\n' + ( '-' * 50 );
              print AdminConfig.show( LP );
              print '-' * 50;
    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

0
 

Author Comment

by:k_satish22
ID: 34939907
I am getting below error when I am executing the script

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP.py C:\A
CS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP.py"; exception information: co
m.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 6, in ?
ImportError: no module named AdminConfig
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34942807
hm.  Sorry,  I guess that my environment automatically made the wsadmin scripting object available in a way that let me do that statement (i.e., line 6).

What happens if you delete, or comment out that line?

e.g.,

Change:

import AdminConfig;

To:

# import AdminConfig;
0
 

Author Comment

by:k_satish22
ID: 34942882
I  getting below error.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py C:
\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
Error: Script must be executed, not imported.

Command: main

Purpose: Use a properties file to modify Listener Ports

  Usage: wsadmin -f main.py <inputFile>

Example: ./wsadmin.sh -f main.py main.txt

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34943186
ooh.  What version of WebSphere are you using?!?

Change line 130 from this:

if __name__ == '__main__' :

To this:

if ( __name__ == '__main__' ) or ( __name__ == 'main' ) :

(sigh)... bit my wsadmin... thank you very much...
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34945251
Did you try that suggestion?

Did it fix your issue?
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34945255
hehe... That typo should have been..

bit BY wsadmin...

0
 

Author Comment

by:k_satish22
ID: 34945910
I am executing the script on WAS 6.1. Still gettings error...
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py C:
\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py"; exception information:
com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  (no code object) at line 0
  File "<string>", line 103
        main();
        ^
SyntaxError: invalid syntax
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34946038
The indentation must be wrong.  Let me attach it as a file.
Update-LP.py.txt
0
 

Author Comment

by:k_satish22
ID: 34946837
Thank you so much for you hard work.
When I executed the above attached script it failed with below error in line 62. I think there extra ")" I removed it and script worked absolutely fine.

I think AdminConfig.Save() is missing Please let me know where to added save and sync node in the script.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\fin\Update_LP.py
 C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
LPname: sample
rest: Dest,QCF,5,1,1
Before:
--------------------------------------------------
[connectionFactoryJNDIName QCF]
[destinationJNDIName Dest]
[maxMessages 1]
[maxRetries 1]
[maxSessions 1]
[name sample]
[stateManagement (cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#StateManageable_129782655134
3)]
--------------------------------------------------
Changes: [['destinationJNDIName', 'Dest'], ['connectionFactoryJNDIName', 'QCF'], ['maxSessions', '5'], ['maxRetries', '1'], ['maxMess
ages', '1']]
 After:
--------------------------------------------------
[connectionFactoryJNDIName QCF]
[destinationJNDIName Dest]
[maxMessages 1]
[maxRetries 1]
[maxSessions 5]
[name sample]
[stateManagement (cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#StateManageable_129782655134
3)]
--------------------------------------------------
WASX7309W: No "save" was performed before the script "C:\ACS\Jython_Scripts\Final_Working_Scripts\fin\Update_LP.py" exited; configura
tion changes will not be saved.

0
 
LVL 41

Accepted Solution

by:
HonorGod earned 500 total points
ID: 34946900
I wanted to be sure that it appeared to be working for you before we "saved" the configuration changes!

Sorry about the extra ')' ... :-(
Update-LP.py.txt
0
 

Author Comment

by:k_satish22
ID: 34947140
Once again Thank you very much for the script. You are the Best.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34947647
Why did you choose your answer as the solution?

Was that a mistake?  I think so... ;-)
0
 

Author Comment

by:k_satish22
ID: 34948253
I am sorry it is a mistake.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 34951283
Thanks for the grade & points.

Good luck & have a great day.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now