Results 1 to 15 of 15

Thread: One File, loads of lines... into a string... how hard could it be?

  1. #1

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718

    One File, loads of lines... into a string... how hard could it be?

    While one of our servers are offline... it's gives me a chance to upload some files locally.

    Here's what we need...

    We have a file, which contains litterally thousands of names which we need to upload to the servers VIA FTP. Each name is on a seperate line, IE.

    john
    craig
    bob

    I need a package which open's FTP to an IP, and creates separate directories called john, craig & bob respectively.

    Anyone with quick idea's???

    I need code BTW, i'm not expecting you code the program

    Regards,

    Paul.

    P.S Brainy buffs v.welcome!
    Last edited by VisionIT; Feb 4th, 2003 at 11:38 AM.

  2. #2
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    I took this off another thread...

    It's actually pretty easy - just use the Inet control. You may have to add the MS Internet Transfer Control 6.0 component to your project first though.

    Just put an Inet control on your form, then put this code wherever:

    ---
    With Inet1
    .URL = "hostname or IP address"
    .UserName = "user name"
    .Password = "password"
    .Execute , "FTP commands"
    Do While .StillExecuting
    DoEvents
    Loop
    End With
    ---

    Your FTP commands statement should look something like this if you want to send a file:

    PUT <local path+file> <remote path+file>

    You may or may not not need the DoEvents command - just play around with it a bit.
    I would guess you would create a loop to read a line from the file, and then issue the FTP command to create a folder using that name.

    for example:
    VB Code:
    1. intFileNbr=FreeFile
    2. OPEN "names.txt" For Input As #intFileNbr
    3. While Not EOF(intFileNbr)
    4. Line Input #intFileNbr, strName
    5. Inet1.Execute "md " & strName
    6. Wend
    7. Close intFileNbr
    Last edited by vfluckey; Feb 4th, 2003 at 11:49 AM.
    Hello? Underpaid code monkey speaking...

  3. #3

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    You lost me where it said Inet!!!

    Anyone care to brief me? Or shoot me... either will do fine ATM.

    Regards,

    Paul.

  4. #4
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    check the above [edited]
    Hello? Underpaid code monkey speaking...

  5. #5

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    cheers m8y... just reading it now...

    You're a damn fast typer


    Regards,

    Paul.

  6. #6
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135

    Smile

    it's untested, but let me know if you get it to work, and post the code if you can, I'd like to see the finished function.
    Hello? Underpaid code monkey speaking...

  7. #7

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    i've tested it... and it doesn't work!

    It says "invalid or unqualified reference on the "URL = " section.

    Help!

    Regards,

    Paul.

  8. #8
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    this is what I would try. I get "file not found" with this exact code
    (of course the file is not found!)

    VB Code:
    1. Dim intFileNbr As Integer
    2.     Dim strName As String
    3.    
    4.     With Inet1
    5.         .URL = "hostname or IP address"
    6.         .UserName = "user name"
    7.         .Password = "password"
    8.  
    9.         intFileNbr = FreeFile        
    10.         Open "names.txt" For Input As #intFileNbr
    11.         While Not EOF(intFileNbr)
    12.             Line Input #intFileNbr, strName
    13.             .Execute "mkdir " & strName
    14.             While .StillExecuting: DoEvents: Wend
    15.         Wend
    16.         Close intFileNbr
    17.     End With
    Hello? Underpaid code monkey speaking...

  9. #9
    Lively Member
    Join Date
    May 2002
    Posts
    94
    It appears that you need to read some information on this subject... Just so happens that Juicy Studio:

    http://www.juicystudio.com/tutorial/vb/http.html

    Has a working FTP example.

    Its a complete application and you can download the code from there.

    Failing that..

    http://www.vbip.com/winsock/winsock_ftp_client_01.asp

    Has a brilliant example, although it would be more complex to understand the underlying code.

    All the best.

    Gav

  10. #10
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    ok, so I missed a comma... I've never worked w/ the Inet control before, but it looked simple enough
    Hello? Underpaid code monkey speaking...

  11. #11

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    the code works... to an extent...

    I get no errors from VB, but the directory never appears???

    I'm confused...

    Thanks for all your help BTW

    Regards,

    Paul.

  12. #12
    Addicted Member
    Join Date
    Jul 2002
    Posts
    135
    hmmmm.... I'd guess the error is in the FTP command...

    do a debug.print of the ftp command, and then try that string in an ftp session. might have to change directories to put it in the right place...

    I dont have an ftp site to test off of, or I'd be more help
    Hello? Underpaid code monkey speaking...

  13. #13

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    Still not working peeps...

    Any other ways to connect to an FTP server and carry out the required process?

    Cheers

    Paul.

  14. #14
    Lively Member
    Join Date
    May 2002
    Posts
    94
    Have you looked at the code i told you about? Juicy Studio and VBIP?

    This should give you a good grounding.

    Gav

  15. #15

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    I have... and thanx for the details.

    Turns-out to be a DNS fault with our ISP's...

    We now have the documents in TCL, and it's worked fine.

    Cheers... all.

    Regards,

    Paul.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width