Results 1 to 5 of 5

Thread: How to Execute a FTP Script....

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Question How to Execute a FTP Script....

    Hi Guys,
    How should I execute a FTP Script to do some action on a FTP Server. For example to get all files from a selected directory of a site we should use the command mget *.*. How should I execute this Script so that I can copy all the files from a FTP Site to the Local Harddrive. Advance thanks for those helping...

  2. #2
    jim mcnamara
    Guest
    Suppose you have a node - 10.10.10.10
    with: username = john
    password hello
    directory where you need to find files is c:\mypath
    You want all of the files form that directory put into
    c:\storage on the machine running the script

    Here's the ftp script - we named it myscript.ftp
    and it lives in c:\
    Code:
    open 10.10.10.10
    john
    hello
    cd \mypath
    lcd \storage
    mget *.*
    bye
    If we were to pretend that you wanted to run the script interactively at the DOS prompt, the command to run it is:

    ftp -is:c:myscript.ftp


    If you want to run this from inside VB

    Code:
    Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    
    Sub RunFTP()
            Dim WindowsDir as string
            Dim retval as long, nSize as Long
            Dim cmd$
            WindowsDir = Space(255)
            retval = GetWindowsDirectory(WindowsDir, nSize)
            WindowsDir = left(WindowsDir, nSize)
            cmd$ = WindowsDir & "ftp -is:c:myscript.ftp"
            Shell cmd$, vbNormalFocus
    End Sub

  3. #3
    jim mcnamara
    Guest
    Here is WinInet sample VB code - vbftpjr from MSDN

    This show how to implement a full-blown ftp application.
    It is a fair amount of code.
    Enjoy....

    Attached Files Attached Files

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Red face Hi Jim,

    I Asked about executing the mget*.*. I know how to use the Get and Put using the Inet Control. Anyway thanks for your code.
    Regards,
    Ramanan.

  5. #5
    jim mcnamara
    Guest
    There is no one-to-one correspondence between mget and some WinInet call or single api.

    You have to look up the host files, then request each one you want be downloaded.

    In other words, you have to figure out how to do mget - the code shows you how to loop thru and get files in a remote directory, then download them.

    Plus, the code is not using the Inet control.

    hth

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