# $language = "Python"
# $interface = "1.0"

import win32gui
import win32com.client

def main(): 
 # dynamic.py (line 521) in ActiveState Python cannot identify property type correctly
 # The following two lines generates required SecureNetTerm definitions to bypass this error.
 from win32com.client import gencache
 gencache.EnsureModule('{ACF74314-0BFA-4825-9E45-3D74D1E7C1ED}', 0, 1, 0)
 true = 1
 snt = win32com.client.Dispatch("SecureNetTerm.Document")
 snt.WindowState = 1
 if snt.Connect("\myCustom\Telnet"):
      if snt.WaitForString("login:",30):
           snt.Send("zkrr01\015")
           if snt.WaitForString("Password:",30):
                result = snt.Prompt("Password","RunExternalSNT","",true)
                snt.Send(result+"\015")
                if snt.WaitForString("/home/zkrr01 $",30):
                     snt.Send("ls\015")
      while snt.Connected:
           pass
      Answer = snt.MessageBox("Disconnected, quit SecureNetTerm application?","RunExternalSNT",4)
      if Answer == 6:
           snt.QuitApp()
 win32gui.MessageBox(0,"Script Complete","Python RunExternalSNT",0)

