Pages

Wednesday, May 6, 2020

Python script to download and run UCM 12c applet

Python script to  download and run admin 
applets of WCC 12c 



#!/usr/bin/python3

import requests,sys,os


## Pass the UCM URL like http://UCMIP:PORT
USERNAME = "weblogic"
PASSWORD = "xx"

print ('run like ./appletDownload.py  http://UCMIP:PORT  <username> <password>' )
print (sys.argv[1])
if (sys.argv[1]):
    URL = sys.argv[1]
else:
    print ('run like ./appletDownload.py  http://UCMIP:PORT  <username> <password>')
    exit()



if (len (sys.argv) ==3 ):
  if (sys.argv[2]):
     USERNAME=sys.argv[2]
  if (sys.argv[3]):
     PASSWORD=sys.argv[3]

LOGIN_URL= URL+"/cs/login/j_security_check?j_username="+USERNAME+"&j_password="+PASSWORD
session_requests = requests.session()

response=session_requests.post(LOGIN_URL)
cookie = response.headers.get('Set-Cookie')
print (cookie)
if ('IntradocLoginState=1' in cookie):
     print ('Authenticated')
     response=session_requests.get(URL+'/cs/idcplg?IdcService=GET_JNLP&App=RepoMan')
     file = open("/tmp/applet.jnlp", 'wb+')
     file.write(response.content)
     file.close()
     print ('applet saved & Starting ')
     os.popen("javaws /tmp/applet.jnlp")

else:
    print ('In Valid login')
#print (response.info())

No comments:

Post a Comment