Micro Focus QTP (UFT) Forums

Full Version: open Putty via QTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello,

Can we open putty via QTP without Terninal Emulator Add-in?
Yes you can. It is just like any other application. Here are two functions I wrote for Putty. You can type in the putty client just like a cmd dialog.

Code:
Function closePutty()
    'This Closes the Putty Window.
    Dim AppCount

    On Error Resume Next
    InfoLog "Closing Putty"
    If window("PuTTY").Exist(0) Then
        window("PuTTY").Type "Quit"
    End If

    If window("PuttyConfig").Exist(0) Then
        Window("PuttyConfig").Close
    End If

    If window("PuTTY").Exist(0) Then
        Window("PuTTY").Close
        Window("PuTTY").Dialog("PuTTY Exit Confirmation").WinButton("OK").Click
    End If
End Function

Function startPutty(sServerIP,sPort,bWindowTitle,sWindowName)
    'This function will start the Putty Application.
    'sServerIP is the Server IP to connect too.
    'sPort is the port to be connecting too.
    'bWindowTitle is whether you want to change the name of the window.
    'sWindowName is the name of the window that will be changed too.
    Dim SettingsFile

    On Error Resume Next
    closePutty
    InfoLog "Starting Putty"
    SettingsFile="C:\Program Files\PuTTY\putty.exe"
    If fso.FileExists(SettingsFile)=False Then 'Verify that Putty is installed.
        ErrorLog  SettingsFile & " does not exist."
        startPutty=False
        Exit Function
    Else
        startPutty=True
    End If
    SystemUtil.Run "C:\Program Files\PuTTY\putty.exe", "", "", ""
    Window("PuttyConfig").WinRadioButton("Telnet").Set
    Window("PuttyConfig").WinEdit("Host Name").Set sServerIP
    Window("PuttyConfig").WinEdit("Port").Set sPort
    If bWindowTitle=True Then
        Window("PuttyConfig").WinTreeView("Category:").Select "Window;Behaviour"
        Window("PuttyConfig").WinEdit("Window title:").Set sWindowName
    End If
    
    Window("PuttyConfig").WinButton("Open").Click
    Wait(5)
    If bWindowTitle=False Then
        window("PuTTY").Activate
        window("PuTTY").Type micReturn
    End If

    ErrorCatcher Err.Number, Err.Description
    Err.Clear
End Function

If you have any further questions please ask.
Thanks for the Reply.

Can you please tell me if it is possible to Telnet an Ip from RUN via QTP without help of TE Add-in?

Regards,
Rachna
Yes, I do it all the time either with both Putty and the cmd prompt.