Hi, is there a way to get the FTP Welcome banner (not the welcome message, but the banner)? What I'm trying to do is to discover several AXIS security cameras over a network using FTP. When I try to FTP into a camera using cmd.exe, the camera answers like:

C:\>ftp <ip address of camera>
Connected to <ip address of camera>
220 Axis 2100 Network Camera 2.12 Feb 05 2001 ready.  <-------
User (<ip address of camera>:(none)):

What I'm trying to get is just the "220 Axis 2100..." part. I already tried sending the ftp command to a cmd and read the StandardOutput, however this doesn't helped, it just skipped that part, like if it wasn't actually part of the cmd process :(.

Is there a way of getting the "220 Axis 2100..." part!?

Thank you very very much for your help!

Recommended Answers

All 3 Replies

I would use a String.SubString method and String.IndexOf methods.

BannerMessage = "Connected to <ip address of camera>" & vbCrLf &
                "220 Axis 2100 Network Camera 2.12 Feb 05 2001 ready." & vbCrLf &
                "User (<ip address of camera>:(none)):"

' extract Axis position (2100)

' check the line for the word Axis.
If BannerMessage.Contains("Axis") Then
    ' split the message into words.
    Dim Words() As String = BannerMessage.Split(" "c)
    Dim AxisPos As Integer

    For i = 0 To Words.Length - 1
        Dim Word As String = Words(i)

        If Word = "Axis" Then
            ' we have found the Axis. get the word after the axis.
             Dim Position As String = Words(i + 1)

             ' convert the word into an integer.
             AxisPos = Integer.Parse(Position)

            Exit For
        End If

End If

' Display the Axis Position; in this case 2100

Thanks Maligui. That wasn't actually my question. My original question was how to retirieve the welcome banner from an FTP session. I will declare this post solved since I managed to do it by using sockets. If anyone is interested send me a PM and I will share the code with him/her.

Thanks again!

I think it's worthwhile to post the answer here so everyone can see it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.