Loading ...
Sorry, an error occurred while loading the content.

Re: [BATCH WORLD] ftp file transfer...

Expand Messages
  • dennis.p.morgan@verizon.com
    I m not affiliated w/ the site I m referring. Perhaps it will fit the bill: http://www.xxcopy.com/xxcopy02.htm (Embedded image moved to file: pic02543.gif)
    Message 1 of 3 , Aug 5, 2004
    • 0 Attachment
      I'm not affiliated w/ the site I'm referring. Perhaps it will fit the
      bill: http://www.xxcopy.com/xxcopy02.htm
      (Embedded image moved to file: pic02543.gif)



      SethFleming
      <Sethfleming@yaho To: batchworld@yahoogroups.com
      o.com> cc:
      Subject: [BATCH WORLD] ftp file transfer...
      08/04/2004 11:47
      PM
      Please respond to
      batchworld





      I have a small batch file which uses mget *.* to transfer files from
      the remote server to my local machine.  Currently the files are not
      many so it doesn't take long but in the future I would like it to
      only transfer those files that are not on my local machine.  If a
      file already exist on my local machine I would like it to just skip
      that file and check the next.  I know this might be complicated for
      batch but I don't have any experience in Perl or other "real"
      languages.  Just checking to see if there might be a way that I'm
      not thinking of.

      Thanks,
      Seth




      To Post a message, send it to:   batchworld@...

      To Unsubscribe, send a blank message to: batchworld-unsubscribe@...



      Yahoo! Groups Sponsor



      ADVERTISEMENT
      click here


      [IMAGE]





      Yahoo! Groups Links

      To visit your group on the web, go to:
      http://groups.yahoo.com/group/batchworld/

      To unsubscribe from this group, send an email to:
      batchworld-unsubscribe@yahoogroups.com

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




      [Non-text portions of this message have been removed]
    • Garry Deane
      ... Unless you can find an ftp client with a bit more smarts than the MS offering, this is a bit difficult. One way to do it is as follows: 1. Use an ftp
      Message 2 of 3 , Aug 8, 2004
      • 0 Attachment
        --- In batchworld@yahoogroups.com, "SethFleming" <Sethfleming@y...>
        wrote:
        > I have a small batch file which uses mget *.* to transfer
        > files from the remote server to my local machine. Currently
        > the files are not many so it doesn't take long but in the
        > future I would like it to only transfer those files that
        > are not on my local machine. If a file already exist on
        > my local machine I would like it to just skip that file
        > and check the next. I know this might be complicated for
        > batch but I don't have any experience in Perl or other "real"
        > languages. Just checking to see if there might be a way
        > that I'm not thinking of.
        >
        > Thanks,
        > Seth

        Unless you can find an ftp client with a bit more smarts than
        the MS offering, this is a bit difficult. One way to do it is
        as follows:

        1. Use an ftp script to get a list of the files on the ftp server
        2. Process the ftp output to extract the file names
        2. Get a list of the files on the local machine
        3. Use FINDSTR to create a list of the files on the server
        but not on the local machine
        4. Create and execute an ftp script to get the individual
        files from the ftp server.

        Below is an example batch file that will do the above. Be warned
        however that you will have to fine tune it for the sort of
        output your server gives. In my case, the ftp server I tested
        against gives lines which end in 0x0d, 0x0d, 0xoA which
        confused FOR no end and required some jumping thru' hoops to
        extract the file names from the ftp log file. You might be able
        to do it easier.

        Also be aware that FINDSTR can be a bit flaky at times. You
        might run into problems with characters in file names that it
        wants to interpret as its own metacharacters.

        Garry

        @echo off
        setlocal enabledelayedexpansion
        set srcdir=%temp%\ftp\files
        set logdir=%temp%\ftp\logs
        set ftpserver=192.168.0.19
        set ftps=%logdir%\ftpscript.txt
        set ftplog=%logdir%\ftplog.txt
        set ftplist=%logdir%\ftplist.txt
        set srclist=%logdir%\srclist.txt

        :: get a directory listing from ftp server
        call :make_ftp_connect
        (echo verbose
        echo ls
        echo quit)>>%ftps%
        ftp -s:%ftps% > %ftplog%
        :: extract file names from %ftplog%
        type nul> %ftplist%
        for /f "tokens=* skip=14" %%a in (%ftplog%) do (
        set line=%%a
        if /i "!line:~0,3!"=="ftp" goto :dirlist
        call echo "%%line%%">> %ftplist%
        )
        :dirlist
        :: get a directory listing from local source
        type nul> %srclist%
        for /f "tokens=*" %%a in ('dir /b /a-d %srcdir%') do (
        echo "%%a">>%srclist%
        )
        :: create the ftp script to get the missing files
        call :make_ftp_connect
        for /f "tokens=*" %%a in (
        'findstr /i /l /v /g:%srclist% %ftplist%') do (
        echo get %%a>>%ftps%
        )
        echo quit>>%ftps%
        :: Go get 'em
        pushd %srcdir%
        ftp -s:%ftps% >> %ftplog%
        goto :eof

        :make_ftp_connect
        :: Create connection commands for an ftp session
        type nul>%ftps%
        (echo open %ftpserver%
        echo anonymous
        echo password
        echo cd /uploads
        )>> %ftps%
        goto :eof
      Your message has been successfully submitted and would be delivered to recipients shortly.