FTP from a VBS file???

Discussion in 'OT Technology' started by FagaBeefe, Sep 20, 2004.

  1. FagaBeefe

    FagaBeefe I live for my initials

    Joined:
    Sep 10, 2002
    Messages:
    1,508
    Likes Received:
    0
    How do I do this? I'm not much of a VBS guy.
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Hell, I'd just do it from a batch file (or call the ftp.exe command from vbs).
     
  3. Keyzs

    Keyzs OT Supporter

    Joined:
    Nov 3, 2003
    Messages:
    814
    Likes Received:
    0
    Location:
    Charlotte, MI
    To upload a file you could do something like:

    Code:
    Const conDOM = "server.domain.tld/" 
    Const conUSR = "Username"
    Const conPWD = "Password"
    Const conDIR = ""
    Const conFIL = "FileToUpload.txt"
    Const conFTP = "upload.ftp"
    
    Dim strOTF
    Dim objFSO
    Dim objOTF
    Dim objWSS
    
    strOTF = "open " & conDOM & vbCrLf
    strOTF = strOTF  & conUSR & vbCrLf
    strOTF = strOTF  & conPWD & vbCrLf
    strOTF = strOTF  & "hash" & vbCrLf
    strOTF = strOTF  & "binary" & vbCrLf
    strOTF = strOTF  & "cd " & conDIR & vbCrLf
    strOTF = strOTF  & "put " & conFIL & vbCrLf
    strOTF = strOTF  & "close" & vbCrLf
    strOTF = strOTF  & "bye" & vbCrLf
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objOTF = objFSO.OpenTextFile(conFTP,2,true)
    objOTF.WriteLine(strOTF)
    Set objOTF = Nothing
    Set objFSO = Nothing
    
    Set objWSS = CreateObject("WScript.Shell")
    objWSS.Run "%comspec% /k ftp -i -s:" & conFTP,2,True
    Set objWSS = Nothing
    
     
  4. FagaBeefe

    FagaBeefe I live for my initials

    Joined:
    Sep 10, 2002
    Messages:
    1,508
    Likes Received:
    0
    Thanks! :bigthumb: :bigthumb: :bigthumb:
     
  5. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Geez that's a lot of work to make a text file :)
     
  6. Keyzs

    Keyzs OT Supporter

    Joined:
    Nov 3, 2003
    Messages:
    814
    Likes Received:
    0
    Location:
    Charlotte, MI
    I borrowed the code, there is no way I personally would do this type of an application in VBS, this is what I have C++ programmers for!
     
  7. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    My point is that in the end you're still using the built in ftp program within windows and your entire code is about writing the script file that the ftp program would use.
     

Share This Page