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
gaurav sharmaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pasha KravtsovSupport EngineerCommented:
You had improper indentation,
Leading whitespace (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements.
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'

Open in new window

0
gaurav sharmaAuthor Commented:
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
0
Pasha KravtsovSupport EngineerCommented:
That's because
if ivtApp in installedapps:

Open in new window

ivtApp doesn't exist. You need to assign it something for example the installed application you're looking for.
ivtApp = "your_app_you_are_looking_for"

Open in new window

Maybe you should read a simple python tutorial?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gaurav sharmaAuthor Commented:
Thanks ..that solved the problem. I am completely new to python and jython programming. Can you suggest some good materials ?
0
Pasha KravtsovSupport EngineerCommented:
No problem! And of course, here is an EE one:
http://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/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.