Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Unix FTP LIST Parser -_Snippet_-
View previous topic :: View next topic  
Author Message
TriSight
Regular


Joined: 12 Oct 2004
Posts: 69
Location: Mobile, AL

PostPosted: Oct 28th, 2004 10:37 AM    Post subject: Unix FTP LIST Parser -_Snippet_- Reply with quote

When you send a LIST command to a unix system, it will return a packet of data (delimited by vbCRLF (carriage return/line feed)). The following is a function to send in a line and have it return an array of information.. I will let you figure out the column positions of the information returned but I will say that the first column is the permissions, the 9th column is the Filename and the 5th column is the Filesize.. the other things you can get on your own :-D Hope this helps someone else ..

[vb:1:670dd5f480]Public Function aGet_UnixTokens(strLineIn As String) As String()
'// Written by Jimmy C. Broadhead, Jr. 10/21/2004

Dim intCurrentToken As Integer
Dim intTokenLength As Integer
Dim intTokenStart As Integer

Dim intStartingPosition As Integer
Dim intLineLength As Integer

Dim astrDataTokens(1 To 9) As String

On Error GoTo GetTokens_Errors
intCurrentToken = 1
intTokenLength = 0

intStartingPosition = 1
intLineLength = Len(strLineIn)

While (intTokenStart + intTokenLength) < intLineLength
If Trim(Mid(strLineIn, intStartingPosition, 1)) = "" Then
If intTokenLength > 0 Then
astrDataTokens(intCurrentToken) = Mid(strLineIn, intTokenStart, intTokenLength)
intCurrentToken = intCurrentToken + 1
intTokenLength = 0
End If
Else
If intTokenLength = 0 Then
intTokenStart = intStartingPosition
End If
intTokenLength = intTokenLength + 1
End If
intStartingPosition = intStartingPosition + 1
Wend
If intTokenLength > 0 Then astrDataTokens(9) = Mid(strLineIn, intTokenStart, intTokenLength + 1)

aGet_UnixTokens = astrDataTokens
On Error GoTo 0

GetTokens_Errors:
' // Error handling code goes here
End Function[/vb:1:670dd5f480]
_________________
/=--_The Nomad_--=\
"Men of lofty genius when they are doing the least work are most active. " - Leonardo da Vinci
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic