Micro Focus QTP (UFT) Forums
open Putty via QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: open Putty via QTP (/Thread-open-Putty-via-QTP)



open Putty via QTP - Rachna - 01-04-2010

hello,

Can we open putty via QTP without Terninal Emulator Add-in?


RE: open Putty via QTP - rdemers25 - 01-05-2010

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.


RE: open Putty via QTP - Rachna - 01-05-2010

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


RE: open Putty via QTP - rdemers25 - 01-05-2010

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