PROC MAIN
WHEN USEREXIT call TERM ;ensure logoff occurs if user exits
dial TELNET "Central TTY 7" ;connect to tty 7
while $DIALING ;necessary loop to pause script
endwhile
if $CARRIER
waitfor "#" ;this is the prompt our pabx presents to a TELNET session
mspause 250
transmit "admin^M" ;our username
transmit "^M" ;= ENTER Key
waitfor "TTY" 2 ;the TTY prompt our pabx sends
IF SUCCESS
;login to central
transmit "LOGI USER^M" ;USER LOGIN
waitfor "PASS?"
transmit "1234^M" ;PASSWORD
waitfor ">"
call captcha
call dothis
call term
ENDIF
endif
ENDPROC
PROC CAPTCHA
WHEN USEREXIT call TERM ;ensure logoff occurs if user exits
string capfile = "File_"
strcat capfile $DATE ;add the DATE to the filename
strreplace capfile "/" "_" ;remove "/" chars as they are invalid for a filename
strcat capfile ".txt" ;denote it as a txt file
set capture path "D:\" ;Capture Directory/Path
set capture file capfile
set capture overwrite ON
clear
capture on
ENDPROC
PROC DOTHIS
WHEN USEREXIT call TERM ;ensure logoff occurs if user exits
transmit "LD 96^M" ;replace this with your process
waitfor "."
transmit "STAT DCH^M"
waitquiet 5 FOREVER
ENDPROC
PROC TERM
capture off
transmit "****" ;log out of LD's
waitfor ">"
transmit "LOGO^M" ;log out of PABX
waitfor ">"
disconnect
ENDPROC