I'm hoping for some insight into a niggly problem... I love Procomm for its versatility... But I want to modify a script to attempt an SSH connection if TELNET fails. I am currently using Procomm to control PuTTY with sendkeystr / sendvkey commands....
My problem is I cannot see/script for what responses occur to PuTTY.
I've been able to monitor the PuTTY Window's Titlebar Text to determine if an error occurs when connecting, but I'd like to monitor what is really occuring within the window...as I can when using Procomm for a TELNET connection.
IS THERE ANYWAY TO MANAGE THIS?
I wrote a script that backsup ~650 Router & Switch configs using CiscoTFTP and TELNET. I need to mod the script to try PUTTY if TELNET fails, which I have done as below.
BUT - I am hoping there is a better way...
My problem is I cannot see/script for what responses occur to PuTTY.
I've been able to monitor the PuTTY Window's Titlebar Text to determine if an error occurs when connecting, but I'd like to monitor what is really occuring within the window...as I can when using Procomm for a TELNET connection.
IS THERE ANYWAY TO MANAGE THIS?
I wrote a script that backsup ~650 Router & Switch configs using CiscoTFTP and TELNET. I need to mod the script to try PUTTY if TELNET fails, which I have done as below.
BUT - I am hoping there is a better way...
Code:
PROC PUTTY
SwapStr = "D:\Putty\putty -load jssh -l <my account name> -pw <my password>"
strcat SwapStr IPADDStr
run SwapStr TaskId
pause 2
taskwin TaskId WinId ; Get window id for task.
winfocus WinId ; Set focus to PUTTY's window.
pause 2
;check to see if Security Alert Occurs
wintext $ACTIVEWIN TempStr
IF strfind TempStr "Security Alert" ; we have a security alert
sendkeystr "y"
pause 2
ENDIF
;end check
if winexists WinId
wintext WinId TempStr
IF NOT strfind TempStr "(inactive)" ;check and make sure window is NOT inactive
sendkeystr "COPY RUN TFTP"
mspause 500
sendvkey 0x0D ;ENTER KEY
pause 1
;obtain IP by stripping '^M' off end of SNMPHost string
SwapStr = SNMPHost
strrev SwapStr
substr TempStr SwapStr 2 13
strrev TempStr
sendkeystr TempStr ;IP of SNMPc machine
pause 1
sendvkey 0x0D ;ENTER KEY
pause 1
;SET FILENAME
strcat NameStr ".cfg" ;add .cfg extension
tempstr = NameStr ;save current value of NameStr
;write PUTTY LOG FILE
if fopen 7 "deleteme.txt" APPEND TEXT ;log file
strcat NameStr ", <-> ,"
strcat NameStr IPADDStr
fputs 7 NameStr
fclose 7
endif
;end PUTTY LOG FILE
SENDKEYSTR NameStr
pause 1
sendvkey 0x0D ;ENTER KEY
pause 12 ; and pray the download finishes soon or we're shot
;close putty window
sendvkey 0x473 ;send ALT-F4
mspause 500
sendvkey 0x0D ;ENTER KEY
ENDIF
else
;putty did not work either
clear ;clearscreen
termputs 3 1 "Connect Failed..."
termputs 3 18 cisco_ip
confail ++ ;count the connection failures
pause 1
call erras
endif
ENDPROC