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

Re: (dos + ftp) - reading input from a txt file for ftp download

Expand Messages
  • Abhijat Singh
    Hi, Thanks very much and apologies for getting back earlier. I will try it out but for the moment the problem stands void because I was just told that we have
    Message 1 of 31 , Sep 15 12:42 PM
      Hi,
      Thanks very much and apologies for getting back earlier. I will try it
      out but for the moment the problem stands void because I was just told
      that we have reduced the exchange code counts from 1874 to 131!! Now the
      same code takes about 2-3 minutes to run and that is absolutely fine
      with me. However, its a good learning for me and I will try the code and
      let you know how it goes.

      Here is another thing that sprang up.
      Suppose I am downloading the data using the previous batch script and I
      come across a file which does not exist or which is not present at the
      moment on the server, I would like that to be captured in some file with
      the date prefixed to it. The underlying idea is obvious - to have a
      daily log file which would tell us what files are missing on the server
      during that run.

      The code uptil now has been:

      @ECHO OFF
      set "file=C:\BATCH\ftpscript2.txt"
      del "%file%" 2>nul

      >>"%file%" echo open <ftpproxy url>
      >>"%file%" echo user <ftpproxy user_id> <ftpproxy pswd>
      >>"%file%" echo user <ftp user_id>@<ftp url> <ftp pswd>

      for /f "delims=" %%a in ('type "master_file.txt"') do (
      >>"%file%" echo mget %%a*
      >>"%file%" echo mdelete %%a*
      )
      >>"%file%" echo quit

      D:
      cd D:\app\inbound
      ftp -v -n -i -s:"%file%"

      C:
      :end

      Regards,
      Abhijat
      P.S. - Group, please let me know if its okay to delete the email thread
      to avoid confusion.
      ------------------------------------------------------------------------\
      ----------------------------------------------


      --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
      >
      >
      > Thanks for replying. I got your point now. I have already given you
      the
      > filenames. They are of the form xxxxmmdd.z. Here xxxx is the stock
      > exchange identifier, ddmm is the date's month and date and z is the
      type
      > of file. What other information in terms of makeup of the files on the
      > server would you need. I thought till this time that the selection of
      > files was pretty random but I will have a second look.
      >
      > The server makeup will only make a difference if an mget xxxx* matches
      > files that you don't want.
      >
      > Try this - it sorts your master list and should write a single MGET
      for
      > each filespec.
      >
      > I've REM ed out the FTP command so you can examine the ftpscript1.txt
      > before you enable the FTP command.
      >
      >
      > @ECHO OFF
      > setlocal enabledelayedexpansion
      > set "file=C:\BATCH\ftpscript1.txt"
      >
      > >>"%file%" echo open <ftpproxy>
      > >>"%file%" echo user ftp_proxy_user_name ftp_proxy_pswd
      > >>"%file%" echo user ftp_user_name@ftp_url ftp_pswd
      >
      > for /f "delims=" %%a in ('sort ^< "master_list.txt"') do (
      > set lead=%%a
      > set lead=!lead:~0,4!
      > if not "!lead!"=="!old!" (
      > >>"%file%" echo mget !lead!*
      > >>"%file%" echo mdelete !lead!*
      > )
      > set old=!lead!
      > )
      >
      > >>"%file%" echo quit
      >
      >
      > S:
      > cd S:\app\inbound\vendors
      > REM ftp -v -n -i -s:"%file%"
      >
      > C:
      > :end
      >




      [Non-text portions of this message have been removed]
    • Abhijat Singh
      Hi, I got it. Many thanks. Its feels great to interact with an expert like you. Thanks again. Kind Regards, Abhijat
      Message 31 of 31 , Sep 17 6:03 AM
        Hi,
        I got it. Many thanks. Its feels great to interact with an expert like you.
        Thanks again.

        Kind Regards,
        Abhijat

        --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
        >
        > On 17/09/2010 21:02, Abhijat Singh wrote:
        > > Hi,
        > > My program will have the output like this:
        > >
        > > 0001,1
        > > 3251,2
        > > 1245,3
        > > 2544,0
        >
        > Assuming your program writes the file "master_file.csv" then this should do:
        >
        >
        > @ECHO OFF
        > set "file=C:\BATCH\ftpscript2.txt"
        > del "%file%" 2>nul
        >
        > >>"%file%" echo open <ftpproxy url>
        > >>"%file%" echo user <ftpproxy user_id> <ftpproxy pswd>
        > >>"%file%" echo user <ftp user_id>@<ftp url> <ftp pswd>
        >
        > for /f "tokens=1,2 delims=," %%a in ('type "master_file.csv"') do (
        > if not %%b EQU 0 (
        > >>"%file%" echo mget %%a*
        > >>"%file%" echo mdelete %%a*
        > )
        > )
        > >> >>"%file%" echo quit
        > D:
        > cd D:\app\inbound
        >
        >
        > for /f "delims=" %%a in (
        > 'type "master_file.txt"'
        > ) do if exist "%%a" del "%%a"
        >
        >
        > ftp -v -n -i -s:"%file%"
        >
        >
        > for /f "delims=" %%a in (
        > 'type "master_file.txt"'
        > ) do if not exist "%%a" >>"file.log" echo missing %date% - %%a
        >
        >
        > C:
        > :end
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.