1

Having issue with the SSH output in Excel VBA with Windows.

I had tried to run the same thing using SSH and it works fine but when I try to do with VBA, it shows it is working but nothing is displayed.

Sub CreateSSHTunnelUsingPutty()
    Dim strFilename As String, strCommandLine As String
    Dim strCurrPath As String
    Dim lngWindowHandle As Long
    Dim strServerPOrt As Long
    Dim strServerUser As String
    Dim strServerPassword As String
    Dim IPAdd As String
    Dim rng As Range, cell As Range

    strServerPOrt = 22                           'Sample POrt
    strServerUser = "username"                   'Sample User Name
    strServerPassword = "password"               'Sample Password
    'Set rng = Range("B2:B75")

    For Each cell In ActiveSheet.Range("B2:B2")
        IPAdd = cell.Value
        strFilename = "Plink.exe"
        strCommandLine = IPAdd & " -P " & strServerPOrt & " -l " & strServerUser & " -pw " & strServerPassword

        'Launch tunnel
        Call lbf_ShellExecute(0, "open", strFilename, strCommandLine, "", 1)
        'Change the last parameter from a one to a zero and the connection window will be hidden.

        Sleep (3000)


'Here i want to give my commands so that output will be displayed on Sheet 1 Starting Row 3

End Sub

Lets say if I put version then it should display the version or top command will result in the all the memory details.

TourEiffel
  • 4,034
  • 2
  • 16
  • 45
Hassan Azhar
  • 43
  • 1
  • 6
  • Please review my edits to see if meaning is as intended. Note that your For Loop does not have a Next. – QHarr Sep 01 '19 at 07:09
  • It looks like what is missing is code to return values from command line to Excel. Something like [example](https://stackoverflow.com/a/54711554/6241235) where stdOut would be assigned to cell.value in loop. – QHarr Sep 01 '19 at 07:11
  • @QHarr That is right, i want to give now commands to see the results in Excel now. – Hassan Azhar Sep 03 '19 at 03:19
  • Did you try the link and replace debug.print with assignment to cell? – QHarr Sep 03 '19 at 07:10

0 Answers0