Search code examples
pythonwin32commainframe

How to connect to the active session of mainframe from Python


How to connect to the active session in mainframe from Python -

import win32com.client

passport = win32com.client.Dispatch("PASSPORT.Session")

session = passport.ActiveSession
if session.connected():
    print("Session active")
else:
    print("Session not active")

It is giving a DDL file missing error when activating the .zws file, and when the session is not active it's giving the message, "Session not active".

Can someone please help?

I am using Python3.8 version


Solution

  • Discovered a possible solution - we can create active session in mainframe using VBA code.

    And connect the macro through python code.