Call Fn_InitPutty ("C:\path\to\putty", "serverhost.com", "username", "password")
Function Fn_InitPutty(strPath, strPuttyUrl, strPuttyUser, strPuttyPass)
Dim blnSuccess
blnSuccess = false
SystemUtil.Run ( strPath & "\putty.exe"), , , SHOW_MAXIMIZED
print "strPath:"& strPath
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Host &Name \(or IP address\)","regexpwndclass:=Edit").SetSelection 0,28
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Host &Name \(or IP address\)","regexpwndclass:=Edit").Set strPuttyUrl
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Select "Session;Logging"
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Log &file name:","regexpwndclass:=Edit").Set strPath + "\putty.log"
Window("regexpwndtitle:=PuTTY Configuration").WinRadioButton("regexpwndtitle:=&Printable output").Set
Window("regexpwndtitle:=PuTTY Configuration").WinRadioButton("regexpwndtitle:=Ask the user every time").Set
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Expand "Connection;SSH"
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Select "Connection;SSH;Auth"
Window("regexpwndtitle:=PuTTY Configuration").WinCheckBox("text:=.* auth \(SSH-2\)").Set "OFF"
Window("regexpwndtitle:=PuTTY Configuration").WinButton("text:=&Open").Click
'If Putty security Alert pops up for the Certificate, click 'Yes'
If Window("regexpwndtitle:= PuTTY Security Alert").Exist(5) Then
Window("regexpwndtitle:= PuTTY Security Alert").WinButton("text:=.*Yes").Click
End If
If Dialog("regexpwndtitle:=PuTTY Log to File").Exist(5) Then
Dialog("regexpwndtitle:=PuTTY Log to File").WinButton("regexpwndtitle:=&Yes").Click
End If
wait 2
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type strPuttyUser
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type micReturn
wait 2
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type strPuttyPass
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type micReturn
wait 5
End Function
Function Fn_SendCmdToPutty(strStringToType, strPath)
wait 1
Const TristateUseDefault = -2, ForReading = 1
Dim objFSO, objPuttyLogFile, objPuttyLogFileTextStream, strPuttyLogFile, strTextLine
If Instr(1,strPath,"putty.log",1) > 0 Then
strPuttyLogFile = strPath
Else
strPuttyLogFile = strPath + "\putty.log"
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objPuttyLogFile = objFSO.GetFile(strPuttyLogFile)
Do
Set objPuttyLogFileTextStream = objPuttyLogFile.OpenAsTextStream(ForReading, TristateUseDefault)
Do while objPuttyLogFileTextStream.atendofstream<>true
strTextLine= objPuttyLogFileTextStream.Readline
Loop
objPuttyLogFileTextStream.Close
Loop until Right(strTextLine, 2) = "$ "
Set objFSO = nothing
Set objPuttyLogFile = nothing
Set objPuttyLogFileTextStream = nothing
'I f blnEnterInput = True then
' TeWindow("TeWindow").TeTextScreen("TeTextScreen").Type strStringToType
' TeWindow("TeWindow").TeTextScreen("TeTextScreen").Type micReturn
' End If
Window("regexpwndclass:=PuTTY").Type strStringToType
Window("regexpwndclass:=PuTTY").Type micReturn
End Function
Function Fn_InitPutty(strPath, strPuttyUrl, strPuttyUser, strPuttyPass)
Dim blnSuccess
blnSuccess = false
SystemUtil.Run ( strPath & "\putty.exe"), , , SHOW_MAXIMIZED
print "strPath:"& strPath
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Host &Name \(or IP address\)","regexpwndclass:=Edit").SetSelection 0,28
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Host &Name \(or IP address\)","regexpwndclass:=Edit").Set strPuttyUrl
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Select "Session;Logging"
Window("regexpwndtitle:=PuTTY Configuration").WinEdit("attached text:=Log &file name:","regexpwndclass:=Edit").Set strPath + "\putty.log"
Window("regexpwndtitle:=PuTTY Configuration").WinRadioButton("regexpwndtitle:=&Printable output").Set
Window("regexpwndtitle:=PuTTY Configuration").WinRadioButton("regexpwndtitle:=Ask the user every time").Set
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Expand "Connection;SSH"
Window("regexpwndtitle:=PuTTY Configuration").WinTreeView("regexpwndclass:=SysTreeView32").Select "Connection;SSH;Auth"
Window("regexpwndtitle:=PuTTY Configuration").WinCheckBox("text:=.* auth \(SSH-2\)").Set "OFF"
Window("regexpwndtitle:=PuTTY Configuration").WinButton("text:=&Open").Click
'If Putty security Alert pops up for the Certificate, click 'Yes'
If Window("regexpwndtitle:= PuTTY Security Alert").Exist(5) Then
Window("regexpwndtitle:= PuTTY Security Alert").WinButton("text:=.*Yes").Click
End If
If Dialog("regexpwndtitle:=PuTTY Log to File").Exist(5) Then
Dialog("regexpwndtitle:=PuTTY Log to File").WinButton("regexpwndtitle:=&Yes").Click
End If
wait 2
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type strPuttyUser
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type micReturn
wait 2
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type strPuttyPass
Window("regexpwndtitle:=PuTTY","regexpwndclass:=PuTTY").Type micReturn
wait 5
End Function
Function Fn_SendCmdToPutty(strStringToType, strPath)
wait 1
Const TristateUseDefault = -2, ForReading = 1
Dim objFSO, objPuttyLogFile, objPuttyLogFileTextStream, strPuttyLogFile, strTextLine
If Instr(1,strPath,"putty.log",1) > 0 Then
strPuttyLogFile = strPath
Else
strPuttyLogFile = strPath + "\putty.log"
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objPuttyLogFile = objFSO.GetFile(strPuttyLogFile)
Do
Set objPuttyLogFileTextStream = objPuttyLogFile.OpenAsTextStream(ForReading, TristateUseDefault)
Do while objPuttyLogFileTextStream.atendofstream<>true
strTextLine= objPuttyLogFileTextStream.Readline
Loop
objPuttyLogFileTextStream.Close
Loop until Right(strTextLine, 2) = "$ "
Set objFSO = nothing
Set objPuttyLogFile = nothing
Set objPuttyLogFileTextStream = nothing
'I f blnEnterInput = True then
' TeWindow("TeWindow").TeTextScreen("TeTextScreen").Type strStringToType
' TeWindow("TeWindow").TeTextScreen("TeTextScreen").Type micReturn
' End If
Window("regexpwndclass:=PuTTY").Type strStringToType
Window("regexpwndclass:=PuTTY").Type micReturn
End Function