Link to home
Start Free TrialLog in
Avatar of gaurav sharma
gaurav sharma

asked on

jyhton scripts to check for application

Below is the Jython script to check if the application exists on server.

import java
import sys
import java
import ConfigParser
import time
import glob
import os
from java.util import Properties

global AdminConfig
global AdminControl
global AdminApp
global AdminTask

installedapps = AdminApp.list().splitlines()
print installedapps
      if ivtApp in installedapps:
            print 'app exists'
                  
            else:
            print 'app does not exists'
            
            
################################################################

The output for       
print installedapps       is

 ['DefaultApplication', 'PlantsByWebSphere', 'SamplesGallery', 'ivtApp', 'query']


I am running the script as

C:\Program Files\IBM\WebSphere\AppServer\bin>wsadmin.bat -f check_application.py
 -lang jython -user username -password mypassword

#########################################################################
The error :

WASX7017E: Exception received while running file "check_application.py"; excepti
on information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  (no code object) at line 0
  File "<string>", line 58
                if "ivtApp" in installedapps:
                ^
SyntaxError: invalid syntax
SOLUTION
Avatar of Pasha Kravtsov
Pasha Kravtsov
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gaurav sharma
gaurav sharma

ASKER

Ok ..used the above script ...Now I get the error

WASX7017E: Exception received while running file "check_application.py"; excepti
on information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 17, in ?
NameError: ivtApp
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks ..that solved the problem. I am completely new to python and jython programming. Can you suggest some good materials ?
No problem! And of course, here is an EE one:
https://www.experts-exchange.com/VP_47.html
I personally haven't watched it but it looks like from the comments and rating that it's a good start
The documentation provided for python & jython have always been my best learning source also:
https://wiki.python.org/jython/LearningJython
http://jython.org/docs/tutorial/indexprogress.html
http://www.jython.org/jythonbook/en/1.0/LangSyntax.html
And here is a beginner friendly one :)
http://www.javalobby.org/articles/jython/