Question

Jython Script that reads values from external file

Asked by: ahobalrao9

AdminTask.mapUsersToAdminRole(['-roleName', 'Administrator', '-userids', '123456'])

The above command creates userid 123456 and maps to Administrator role at cell level.

Can some one help me in doing this...by  providing the variables and define these varialbe values in a another text file.

AdminTask.mapUsersToAdminRole(['-roleName', 'variable', '-userids', 'variable'])

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-04 at 11:52:55ID24625836
Topics

Automation

,

IBM Websphere Application Server

Participating Experts
1
Points
500
Comments
29

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. **Dynamic Map/External Feed**
    Ok, I want to build a map with certain locations on it represented by dots. Just like a regular map. I would like these dot's positions to be determined by an external source. IE: A user can go into an XML file and add or delete ceratin coordinates and it would result on ...
  2. UserID
    We have an application where users login using their Windows Authentication user name , but the connection goes to the database using a generic userid "ABC123" for all the users. My question is , when a user makes some changes to the data , like insert , update,dele...
  3. How to get UserID
    Hi There, I have some code that is reading in a file off the network and processing it. The location of the file is the user's home diriectory.... like \\uws-linux1\homes\lbobzie. Many of my users map a drive to their home dir but they don't all use the same drive lett...
  4. What are the vulnerabilities of having session variables and…
    What are the vulnerabilities of having session variables and userids in websphere.
  5. websphere mapping the roles
    Hi, I have an issue in websphere 6.1 that I created the users and assigned the roles of administrator and turned on the global security and restarted the environment and I was able to login and do all the administration tasks. But I can't add any more users and can't change t...
  6. Implement Roles in
    I have an ASP.NET application (in C#.) I have a custom login authentication procedure. Once a user is authenticated I want to take advantage of the asp.net roles. Can I integrate the asp.net roles feature into my existing authentication procedure? And if so, how would I d...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: HonorGodPosted on 2009-08-04 at 12:22:29ID: 25017214

I'm sorry, but I don't understand.  Please forgive me.
Are you trying to read an input file that contains the roleName and userids values from a text file, and issue the corresponding mapUsersToAdminRole() call?

p.s. I've requested assistance for this question to either get it move to the "IBM WebSphere Application Server" zone, or at least have that zone added.

 

by: HonorGodPosted on 2009-08-04 at 12:26:40ID: 25017255

or, are you perhaps requesting help with writing a Jython script that allows you to execute a command to perform this kind of request.

For example, something like this:

wsadmin -conntype none -lang jython -f mapUsersToAdminRole.py --Administrator 12345 11111 22222

                                              
1:

Select allOpen in new window

 

by: ahobalrao9Posted on 2009-08-04 at 12:38:35ID: 25017359


I apolizise for not putting it striaght.

You are right ...I'm trying to read an input file that contains the roleName and userids values from a text file.

 

by: HonorGodPosted on 2009-08-04 at 13:25:24ID: 25017787

next question, what will the input "look" like?

For example:

- what delimiter will exist between the roleName and userid values?
- how many userid's can exist for each roleName?

 

by: ahobalrao9Posted on 2009-08-04 at 14:34:15ID: 25018426



The input will be like...userid,role name

The delimiter would be , (comma).

The user id can be mapped to more than one role name.

For example:  12345,Administrator,Adminsecuritymanager
Where 12345 is useris and Administrator,Adminsecuritymanager are roles

 

by: HonorGodPosted on 2009-08-04 at 18:37:13ID: 25019649

Something like this perhaps?

With this input:
----------------------------------------------------------------------
12345,Administrator,Adminsecuritymanager
11111,Bill,Jack,Bob
----------------------------------------------------------------------

Command:
----------------------------------------------------------------------
wsadmin -conntype none -lang jython -f mapUsersToAdminRole.py map.dat
----------------------------------------------------------------------

Generated output:
----------------------------------------------------------------------
Processing: map.dat
>>> 12345,Administrator,Adminsecuritymanager
mapUsersToAdminRole( ['-roleName', 'Administrator', '-userids', '12345'] )
mapUsersToAdminRole( ['-roleName', 'Adminsecuritymanager', '-userids', '12345'] )
>>> 11111,Bill,Jack,Bob
mapUsersToAdminRole( ['-roleName', 'Bill', '-userids', '11111'] )
mapUsersToAdminRole( ['-roleName', 'Jack', '-userids', '11111'] )
mapUsersToAdminRole( ['-roleName', 'Bob', '-userids', '11111'] )
----------------------------------------------------------------------

import sys
 
filename = sys.argv[ 0 ]
print 'Processing: ' + filename
 
f = open( filename )
data = f.read()
f.close()
 
for line in data.splitlines() :
  print '>>>', line
  info = line.split( ',' )
  for role in info[ 1: ] :
    print "mapUsersToAdminRole( ['-roleName', '%s', '-userids', '%s'] )" % ( role, info[ 0 ] )

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: ahobalrao9Posted on 2009-08-04 at 20:17:34ID: 25019924



Thank you..will try and update.

Thanks again

 

by: HonorGodPosted on 2009-08-05 at 04:38:16ID: 25022190

Note that it doesn't actually use the AdminTask object.  Right?

If you really want it to perform the action, you need to change the print statement in line 14, or add a call to the AdminTask.mapUsersToAdminRole() call immediately after line 14 with the same indentation...

 

by: ahobalrao9Posted on 2009-08-05 at 11:39:36ID: 25026643


The above code works as same...but my intension is to use this to actually make configuration.
So when i added  AdminTask.mapUsersToAdminRole() call immediately after line 14 with the same indentation...it's throws error saying  "Required parameter roleName is not found for command mapUsersToAdminRole"  Following is the sample output

WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[map.dat]"
Processing: map.dat
>>> 123456,Administrator
AdminTask.mapUsersToAdminRole( ['-roleName', 'Administrator', '-userids', '123456'] )
WASX7017E: Exception received while running file "A1.py"; exception information: com.ibm.websphere.management.cmdframework.RequiredParameterNotFoundException: ADMF0002E: Required parameter roleName is not found for command mapUsersToAdminRole.

 

by: HonorGodPosted on 2009-08-05 at 11:55:22ID: 25026802

WASX7017E -

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rtrb_wsadminprobs.html#rtrb_wsadminprobs__wasx7016e

----------------------------------------------------------------------
These errors can occur because there are UTF-8 characters in the file that are not valid. The default codepage for RHEL 3 is UTF-8 (en_US.UTF-8). When doing a text file read through Java" code, the program assumes all characters are UTF-8 encoded. There might be one or more characters in the file that are not part of the UTF-8 specification, causing the load to fail. An easy way to determine if a character that is not valid is causing the error is to enter export LANG=C and run the script again. If you determine that the problem is a character that is not valid:

   1. Open a new text reader on the file.
   2. Read it one character at a time.
   3. Print the character that is not valid.
   4. When you press the back characters, you get the exception and will then know which of the characters is causing the error.
   5. Remove any characters that are not valid, then run the script again
----------------------------------------------------------------------

 

by: HonorGodPosted on 2009-08-05 at 17:25:42ID: 25029180

I bet that A1.py is unicode, and not UTF-8...

 

by: HonorGodPosted on 2009-08-09 at 06:51:03ID: 25054212

Have you had a chance to check whether or not A1.py uses Unicode characters?

 

by: ahobalrao9Posted on 2009-08-09 at 07:30:33ID: 25054319


Yes..i could find no unicode characters.

As i mentioned earlier,the above code works fine with the print statemant.But when i use the AdminTask

command..i get the error . That where i was struck and tring to debug.

If you have any thoughts on that could you please let know.

Thank you

 

by: HonorGodPosted on 2009-08-09 at 10:11:59ID: 25054888

Looking back at http://#a25026643 I see that I was looking at the wrong part of the error message.  The important part is this:

Required parameter roleName is not found ...

Exactly what AdminTask command were you trying to execute?

 

by: ahobalrao9Posted on 2009-08-10 at 06:40:50ID: 25059798

Following  is the AdminTask command  i'm trying to use
AdminTask.mapUsersToAdminRole

The full command i'm using is
AdminTask.mapUsersToAdminRole(( ['-roleName', 'Administrator', '-userids', '123456'] )

 

by: HonorGodPosted on 2009-08-10 at 08:33:29ID: 25060877

That command has syntax problems...

- 2 open parenthesis '('
- 1 closing parenthesis ')'
- Note: If you do not specify this parameter, the cell level authorization group is assumed.
? Do you want the roleName to be "Administrator" with a capital 'A' ?

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rxml_atauthorizationgroup.html?resultof=%22mapUsersToAdminRole%22%20%22mapuserstoadminrol%22%20#rxml_atauthorizationgroup__cmd13

AdminTask.mapUsersToAdminRole(( ['-roleName', 'Administrator', '-userids', '123456'] )

                                              
1:

Select allOpen in new window

 

by: ahobalrao9Posted on 2009-08-10 at 10:44:47ID: 25062158

That's my typing mistake.There would be only one open/close paranthesis.

Yes,I'm aware that this would configure at cell level and .Yes,the role name has to be with a capital 'A' .

 

by: HonorGodPosted on 2009-08-10 at 10:49:47ID: 25062201

ok, please attach the script that you are trying to execute, as well as the sample output of an attempt to execute it (as well as any input file).

 

by: ahobalrao9Posted on 2009-08-10 at 13:09:04ID: 25063567

Attached is the zip file that contain two files, code.txt(renamed to txt,coz it didnot allow to upload with .py extension) is the jython code and file.txt is the external file from which the values are read.

Also , i've attached the out put.

Please let know if any more info needed.

[WAS/Dmgr01/bin]# ./wsadmin.sh -lang jython -f code.py file.txt
WASX7209I: Connected to process "dmgr" on node XXXXXX using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[file.txt]"
Processing: file.txt
>>> 123456,Administrator,adminsecuritymanager
AdminTask.mapUsersToAdminRole( ['-roleName', 'Administrator', '-userids', '123456'] )
WASX7017E: Exception received while running file "code.py"; exception information: com.ibm.websphere.management.cmdframework.RequiredParameterNotFoundException: ADMF0002E: Required parameter roleName is not found for command mapUsersToAdminRole.
                                              
1:
2:
3:
4:
5:
6:
7:

Select allOpen in new window

  • files.zip
    • 601 bytes

    file that had jython code and external file that's passed as parameter

 

by: HonorGodPosted on 2009-08-10 at 13:22:33ID: 25063688

Very, very strange.

Exactly what version of WebSphere is being used?

from the Dmgr01/bin, exeucte:

./versionInfo.sh

I need all four (dot separated) values.

Thanks!

 

by: ahobalrao9Posted on 2009-08-10 at 15:15:23ID: 25064606



Websphere Application Server 6.1.

I haven't executed the command,as i'm done for the day.I could provide the exact info ..tomorow.

 

by: HonorGodPosted on 2009-08-10 at 17:53:11ID: 25065464

Thanks.

 

by: ahobalrao9Posted on 2009-08-11 at 06:14:23ID: 25068590

Hi,Following is the out put..

Installation
--------------------------------------------------------------------------------
Product Directory        /WAS/AppServer
Version Directory        /WAS/AppServer/properties/version
DTD Directory            /WAS/AppServer/properties/version/dtd
Log Directory            /WAS/AppServer/logs
Backup Directory         /WAS/AppServer/properties/version/nif/backup
TMP Directory            /var/tmp

Product List
--------------------------------------------------------------------------------
ND                       installed

Installed Product
--------------------------------------------------------------------------------
Name                     IBM WebSphere Application Server - ND
Version                  6.1.0.25
ID                       ND

 

by: HonorGodPosted on 2009-08-11 at 07:01:06ID: 25069117

wow, that's the first time that I've had someone be at the recommended fix level!


Thanks also for providing the files (http#a25063567)

If we look at the script, we find the problem...


Note how the statement that actually calls, or invokes the mapUsersToAdminRole method doesn't include any parameters.

Change this line:

AdminTask.mapUsersToAdminRole()

To this:

AdminTask.mapUsersToAdminRole( ['-roleName', role, '-userids', info[ 0 ] ] )

Be sure that this statement is exactly the same indentation at the print statement  it follows.

     print "AdminTask.mapUsersToAdminRole( ['-roleName', '%s', '-userids', '%s'] )" % ( role, info[ 0 ] )
     AdminTask.mapUsersToAdminRole()
                                              
1:
2:

Select allOpen in new window

 

by: ahobalrao9Posted on 2009-08-11 at 18:50:43ID: 25075129



Great.Thank you.Everything works as expected.

Thanks again.

 

by: ahobalrao9Posted on 2009-08-11 at 18:52:07ID: 31611603


Wonderful...this had been really helpful.

Great Appreciation.

Thanks

 

by: HonorGodPosted on 2009-08-11 at 18:55:20ID: 25075148

Excellent.  I'm glad to have been able to help.

Thanks for the grade & the points.

Good luck & have a great day.

 

by: ahobalrao9Posted on 2009-08-12 at 06:44:40ID: 25078627



Thank you..you too have a great day.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...