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

Re: [BATCH WORLD] ftp download + file name based on day of the week

Expand Messages
  • foxidrive
    ... I am assuming there is a text file with the text in it exactly as you outlined below - except the word and is not there - and that on any day there can
    Message 1 of 15 , Oct 11, 2010
    • 0 Attachment
      On 12/10/2010 03:52, Abhijat Singh wrote:


      > Is the format above already set in stone? Sorry didn't get the question.

      I am assuming there is a text file with the text in it exactly as you
      outlined below - except the word 'and' is not there - and that on any
      day there can be more than one, or none, files to download. Is that right?

      > Its just that there are two files to be downloaded on Saturday. They can be qrst.zip and uvwx.zip.

      Or are you saying that the schedule below never changes?


      >>> I have a script in which I have to download file based on what day is it today. For example, if today is Wednesday, the file to be downloaded is efgh.zip. The day and file mapping can be as below:
      >>>
      >>> Tuesday: abcd.zip
      >>> Wednesday: efgh.zip
      >>> Thursday: ijkl.zip
      >>> Friday: mnop.zip
      >>> Saturday: qrst.zip and uvwx.zip


      Please don't top post.
    • Abhijat Singh
      Hi FoxiDrive, Apologies if I am confusing you. All I have to say is there is a specific file that I have to download on a specific day. Yes, there can be a
      Message 2 of 15 , Oct 11, 2010
      • 0 Attachment
        Hi FoxiDrive,
        Apologies if I am confusing you. All I have to say is there is a specific file that I have to download on a specific day. Yes, there can be a chance that the file to be downloaded on a specific day is not present. The script may then simply skip the download. However, there will be only one file to be downloaded for a day except Saturdays when there will be two files, the daily file as all the other days and a special weekly file which will be a consolidation of all the daily files. This weekly file will be used mostly for the comparision purposes in my analysis.

        There is no text file as such. However, I can create a text file , lets say, details.txt with file-day mapping.

        The content of details.txt (for the argument sake) can be

        Tuesday: abcd.zip
        Wednesday: efgh.zip
        Thursday: ijkl.zip
        Friday: mnop.zip
        Saturday: qrst.zip,uvwx.zip

        or it can be in some other format.

        I hope I am making things clearer and not firther confusing you.

        Thanks very much!

        Kind Regards,
        Abhijat

        --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
        >
        > On 12/10/2010 03:52, Abhijat Singh wrote:
        >
        >
        > > Is the format above already set in stone? Sorry didn't get the question.
        >
        > I am assuming there is a text file with the text in it exactly as you
        > outlined below - except the word 'and' is not there - and that on any
        > day there can be more than one, or none, files to download. Is that right?
        >
        > > Its just that there are two files to be downloaded on Saturday. They can be qrst.zip and uvwx.zip.
        >
        > Or are you saying that the schedule below never changes?
        >
        >
        > >>> I have a script in which I have to download file based on what day is it today. For example, if today is Wednesday, the file to be downloaded is efgh.zip. The day and file mapping can be as below:
        > >>>
        > >>> Tuesday: abcd.zip
        > >>> Wednesday: efgh.zip
        > >>> Thursday: ijkl.zip
        > >>> Friday: mnop.zip
        > >>> Saturday: qrst.zip and uvwx.zip
        >
        >
        > Please don't top post.
        >
      • foxidrive
        ... I am not confused, I was merely seeking clarification as you were not specific enough. PLEASE LEARN NOT TO TOP POST. ... @echo off set
        Message 3 of 15 , Oct 11, 2010
        • 0 Attachment
          On 12/10/2010 04:58, Abhijat Singh wrote:

          > Apologies if I am confusing you.

          I am not confused, I was merely seeking clarification as you were not
          specific enough.

          PLEASE LEARN NOT TO TOP POST.


          This script is untested:


          :: Day using WSH
          @echo off
          set TmpFile="%temp%.\tmp.vbs"
          echo> %TmpFile% n=Now
          echo>>%TmpFile% With WScript
          echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
          echo>>%TmpFile% End With
          cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
          call "%temp%.\tmp.bat"
          del "%temp%.\tmp.bat"
          del %TmpFile%
          set TmpFile=
          :: echo The full weekday name is "%dow2%"

          set "script=C:\BATCH\ftpscript1.txt"

          del "%script%" 2>nul

          if %dow2% NEQ Sunday (
          >> "%script%" echo open <ftpprxy_url>
          >> "%script%" echo user <ftp_proxy user id> <ftp_proxy pswd>
          >> "%script%" echo user <ftp_userid>@<ftp_url> <ftp_pswd>
          >> "%script%" echo cd qfs
          if %dow2% EQU Monday >> "%script%" echo get fileA.zip
          if %dow2% EQU Tuesday >> "%script%" echo get fileB.zip
          if %dow2% EQU Wednesday >> "%script%" echo get fileC.zip
          if %dow2% EQU Thursday >> "%script%" echo get fileD.zip
          if %dow2% EQU Friday >> "%script%" echo get fileE.zip
          if %dow2% EQU Saturday >> "%script%" echo get fileF.zip
          if %dow2% EQU Saturday >> "%script%" echo get fileG.zip
          >> "%script%" echo quit

          S:
          cd S:\app\inbound\vendors
          ftp -v -n -i -s:"%script%"
          C:

          del "%script%" 2>nul
          )
        • Glenn B. Lawler
          Here is a way to write a batch with sections for each day of the week without depending on Windows Scripting Host in only a few lines: FOR /F usebackq
          Message 4 of 15 , Oct 11, 2010
          • 0 Attachment
            Here is a way to write a batch with sections for each day of the week
            without depending on Windows Scripting Host in only a few lines:

            FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i
            SET WeekDay=%WeekDay:~0,3%
            GOTO %WeekDay%
            :Mon
            :Tue
            :Wed
            :Thu
            :Fri
            :Sat
            :Sun

            Glenn Lawler
            www.incodesystems.com

            -----Original Message-----
            From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
            Behalf Of foxidrive
            Sent: Monday, October 11, 2010 1:48 PM
            To: batchworld@yahoogroups.com
            Subject: Re: [BATCH WORLD] ftp download + file name based on day of the week

            On 12/10/2010 04:58, Abhijat Singh wrote:

            > Apologies if I am confusing you.

            I am not confused, I was merely seeking clarification as you were not
            specific enough.

            PLEASE LEARN NOT TO TOP POST.


            This script is untested:


            :: Day using WSH
            @echo off
            set TmpFile="%temp%.\tmp.vbs"
            echo> %TmpFile% n=Now
            echo>>%TmpFile% With WScript
            echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
            echo>>%TmpFile% End With
            cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
            call "%temp%.\tmp.bat"
            del "%temp%.\tmp.bat"
            del %TmpFile%
            set TmpFile=
            :: echo The full weekday name is "%dow2%"

            set "script=C:\BATCH\ftpscript1.txt"

            del "%script%" 2>nul

            if %dow2% NEQ Sunday (
            >> "%script%" echo open <ftpprxy_url>
            >> "%script%" echo user <ftp_proxy user id> <ftp_proxy pswd> >> "%script%"
            echo user <ftp_userid>@<ftp_url> <ftp_pswd> >> "%script%" echo cd qfs
            if %dow2% EQU Monday >> "%script%" echo get fileA.zip
            if %dow2% EQU Tuesday >> "%script%" echo get fileB.zip
            if %dow2% EQU Wednesday >> "%script%" echo get fileC.zip if %dow2% EQU
            Thursday >> "%script%" echo get fileD.zip
            if %dow2% EQU Friday >> "%script%" echo get fileE.zip
            if %dow2% EQU Saturday >> "%script%" echo get fileF.zip if %dow2% EQU
            Saturday >> "%script%" echo get fileG.zip >> "%script%" echo quit

            S:
            cd S:\app\inbound\vendors
            ftp -v -n -i -s:"%script%"
            C:

            del "%script%" 2>nul
            )
          • Glenn B. Lawler
            Lost the line breaks in the transfer. Here is how it should be: FOR /F usebackq delims== %%i IN (`DATE /T`) DO SET WeekDay=%%i SET WeekDay=%WeekDay:~0,3%
            Message 5 of 15 , Oct 11, 2010
            • 0 Attachment
              Lost the line breaks in the transfer. Here is how it should be:

              FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i
              SET WeekDay=%WeekDay:~0,3%
              GOTO %WeekDay%
              :Mon
              :Tue
              :Wed
              :Thu
              :Fri
              :Sat
              :Sun

              Glenn Lawler
              www.incodesystems.com

              -----Original Message-----
              From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
              Behalf Of Glenn B. Lawler
              Sent: Monday, October 11, 2010 2:08 PM
              To: batchworld@yahoogroups.com
              Subject: RE: [BATCH WORLD] ftp download + file name based on day of the week

              Here is a way to write a batch with sections for each day of the week
              without depending on Windows Scripting Host in only a few lines:

              FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i SET
              WeekDay=%WeekDay:~0,3% GOTO %WeekDay% :Mon :Tue :Wed :Thu :Fri :Sat :Sun

              Glenn Lawler
              www.incodesystems.com

              -----Original Message-----
              From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
              Behalf Of foxidrive
              Sent: Monday, October 11, 2010 1:48 PM
              To: batchworld@yahoogroups.com
              Subject: Re: [BATCH WORLD] ftp download + file name based on day of the week

              On 12/10/2010 04:58, Abhijat Singh wrote:

              > Apologies if I am confusing you.

              I am not confused, I was merely seeking clarification as you were not
              specific enough.

              PLEASE LEARN NOT TO TOP POST.


              This script is untested:


              :: Day using WSH
              @echo off
              set TmpFile="%temp%.\tmp.vbs"
              echo> %TmpFile% n=Now
              echo>>%TmpFile% With WScript
              echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
              echo>>%TmpFile% End With
              cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
              call "%temp%.\tmp.bat"
              del "%temp%.\tmp.bat"
              del %TmpFile%
              set TmpFile=
              :: echo The full weekday name is "%dow2%"

              set "script=C:\BATCH\ftpscript1.txt"

              del "%script%" 2>nul

              if %dow2% NEQ Sunday (
              >> "%script%" echo open <ftpprxy_url>
              >> "%script%" echo user <ftp_proxy user id> <ftp_proxy pswd> >> "%script%"
              echo user <ftp_userid>@<ftp_url> <ftp_pswd> >> "%script%" echo cd qfs
              if %dow2% EQU Monday >> "%script%" echo get fileA.zip
              if %dow2% EQU Tuesday >> "%script%" echo get fileB.zip
              if %dow2% EQU Wednesday >> "%script%" echo get fileC.zip if %dow2% EQU
              Thursday >> "%script%" echo get fileD.zip
              if %dow2% EQU Friday >> "%script%" echo get fileE.zip
              if %dow2% EQU Saturday >> "%script%" echo get fileF.zip if %dow2% EQU
              Saturday >> "%script%" echo get fileG.zip >> "%script%" echo quit

              S:
              cd S:\app\inbound\vendors
              ftp -v -n -i -s:"%script%"
              C:

              del "%script%" 2>nul
              )
            • foxidrive
              ... Glenn, thanks for your post. The format of date /t is dependant on the locale and also the users settings and it may not contain a day keyword, which is
              Message 6 of 15 , Oct 11, 2010
              • 0 Attachment
                On 12/10/2010 06:11, Glenn B. Lawler wrote:
                > Lost the line breaks in the transfer. Here is how it should be:
                >
                > FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i
                > SET WeekDay=%WeekDay:~0,3%
                > GOTO %WeekDay%
                > :Mon
                > :Tue
                > :Wed
                > :Thu
                > :Fri
                > :Sat
                > :Sun

                Glenn, thanks for your post.

                The format of date /t is dependant on the locale and also the users
                settings
                and it may not contain a day keyword, which is why I chose to use WSH.
              • Glenn B. Lawler
                ... settings and it may not contain a day keyword, which is why I chose to use WSH. Glad you brought up the regional settings issue. We actually don t use that
                Message 7 of 15 , Oct 11, 2010
                • 0 Attachment
                  >On 12/10/2010 06:11, Glenn B. Lawler wrote:
                  >> Lost the line breaks in the transfer. Here is how it should be:
                  >>
                  >> FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i SET
                  >> WeekDay=%WeekDay:~0,3% GOTO %WeekDay% :Mon :Tue :Wed :Thu :Fri :Sat
                  >> :Sun
                  >
                  >Glenn, thanks for your post.
                  >
                  >The format of date /t is dependant on the locale and also the users
                  settings and it may not contain a day keyword, which is why I chose to use
                  WSH.

                  Glad you brought up the regional settings issue. We actually don't use that
                  ourselves. I wrote a program many years ago that sets the ERRORLEVEL to a
                  number corresponding to the day of the week.
                • Abhijat Singh
                  ... Hi Foxidrive, The script provided by you worked very well on my machine. However, this part of the script doesn t seem to work on a production server (may
                  Message 8 of 15 , Oct 12, 2010
                  • 0 Attachment
                    --- In batchworld@yahoogroups.com, "Glenn B. Lawler" <gblawler@...> wrote:
                    >
                    > >On 12/10/2010 06:11, Glenn B. Lawler wrote:
                    > >> Lost the line breaks in the transfer. Here is how it should be:
                    > >>
                    > >> FOR /F "usebackq delims==" %%i IN (`DATE /T`) DO SET WeekDay=%%i SET
                    > >> WeekDay=%WeekDay:~0,3% GOTO %WeekDay% :Mon :Tue :Wed :Thu :Fri :Sat
                    > >> :Sun
                    > >
                    > >Glenn, thanks for your post.
                    > >
                    > >The format of date /t is dependant on the locale and also the users
                    > settings and it may not contain a day keyword, which is why I chose to use
                    > WSH.
                    >
                    > Glad you brought up the regional settings issue. We actually don't use that
                    > ourselves. I wrote a program many years ago that sets the ERRORLEVEL to a
                    > number corresponding to the day of the week.
                    >

                    Hi Foxidrive,
                    The script provided by you worked very well on my machine. However, this part of the script doesn't seem to work on a production server (may be due to difference in settings).
                    ------------------------------------------
                    set TmpFile="%temp%.\tmp.vbs"
                    echo> %TmpFile% n=Now
                    echo>>%TmpFile% With WScript
                    echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
                    echo>>%TmpFile% End With
                    cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
                    call "%temp%.\tmp.bat"
                    del "%temp%.\tmp.bat"
                    del %TmpFile%
                    set TmpFile=
                    echo The full weekday name is "%dow2%"
                    ----------------------------------------------

                    I get error as "The filename, directory name, or volume label syntax is incorrect." 8 times. Then "The full weekday name is "" " and finally, "Sunday was unexpected at this time"

                    I think the difference is in the tmp file settings. Can we have something without involving tmp files. Something like
                    n=Now
                    set dow2=" + WeekDayName(Weekday(n))

                    Kind Regards,
                    Abhijat
                  • foxidrive
                    ... Can you try this code on the production server to see what it generates? @echo off set TmpFile= %temp% tmp.vbs echo %TmpFile% n=Now echo %TmpFile% With
                    Message 9 of 15 , Oct 12, 2010
                    • 0 Attachment
                      On 12/10/2010 21:39, Abhijat Singh wrote:
                      > The script provided by you worked very well on my machine. However, this part of the script doesn't seem to work on a production server (may be due to difference in settings).
                      > ------------------------------------------
                      > set TmpFile="%temp%.\tmp.vbs"
                      > echo> %TmpFile% n=Now
                      > echo>>%TmpFile% With WScript
                      > echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
                      > echo>>%TmpFile% End With
                      > cscript //nologo "%temp%.\tmp.vbs"> "%temp%.\tmp.bat"
                      > call "%temp%.\tmp.bat"
                      > del "%temp%.\tmp.bat"
                      > del %TmpFile%
                      > set TmpFile=
                      > echo The full weekday name is "%dow2%"
                      > ----------------------------------------------
                      >
                      > I get error as "The filename, directory name, or volume label syntax is incorrect." 8 times. Then "The full weekday name is "" " and finally, "Sunday was unexpected at this time"
                      >
                      > I think the difference is in the tmp file settings. Can we have something without involving tmp files. Something like
                      > n=Now
                      > set dow2=" + WeekDayName(Weekday(n))

                      Can you try this code on the production server to see what it generates?

                      @echo off
                      set TmpFile="%temp%\tmp.vbs"
                      echo> %TmpFile% n=Now
                      echo>>%TmpFile% With WScript
                      echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
                      echo>>%TmpFile% End With
                      cscript //nologo "%temp%\tmp.vbs" > "%temp%\tmp.bat"
                      call "%temp%\tmp.bat"
                      del "%temp%\tmp.bat"
                      del %TmpFile%
                      set TmpFile=
                      echo The full weekday name is "%dow2%"
                      echo "%temp%"
                      pause
                    • Abhijat Singh
                      ... Hi Forxidrive, Thanks for replying. This is what I get: D: users abhijat Windows Scripting practice.bat The filename, directory name, or volume label
                      Message 10 of 15 , Oct 13, 2010
                      • 0 Attachment
                        --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
                        >
                        > On 12/10/2010 21:39, Abhijat Singh wrote:
                        > > The script provided by you worked very well on my machine. However, this part of the script doesn't seem to work on a production server (may be due to difference in settings).
                        > > ------------------------------------------
                        > > set TmpFile="%temp%.\tmp.vbs"
                        > > echo> %TmpFile% n=Now
                        > > echo>>%TmpFile% With WScript
                        > > echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
                        > > echo>>%TmpFile% End With
                        > > cscript //nologo "%temp%.\tmp.vbs"> "%temp%.\tmp.bat"
                        > > call "%temp%.\tmp.bat"
                        > > del "%temp%.\tmp.bat"
                        > > del %TmpFile%
                        > > set TmpFile=
                        > > echo The full weekday name is "%dow2%"
                        > > ----------------------------------------------
                        > >
                        > > I get error as "The filename, directory name, or volume label syntax is incorrect." 8 times. Then "The full weekday name is "" " and finally, "Sunday was unexpected at this time"
                        > >
                        > > I think the difference is in the tmp file settings. Can we have something without involving tmp files. Something like
                        > > n=Now
                        > > set dow2=" + WeekDayName(Weekday(n))
                        >
                        > Can you try this code on the production server to see what it generates?
                        >
                        > @echo off
                        > set TmpFile="%temp%\tmp.vbs"
                        > echo> %TmpFile% n=Now
                        > echo>>%TmpFile% With WScript
                        > echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
                        > echo>>%TmpFile% End With
                        > cscript //nologo "%temp%\tmp.vbs" > "%temp%\tmp.bat"
                        > call "%temp%\tmp.bat"
                        > del "%temp%\tmp.bat"
                        > del %TmpFile%
                        > set TmpFile=
                        > echo The full weekday name is "%dow2%"
                        > echo "%temp%"
                        > pause
                        >
                        Hi Forxidrive,
                        Thanks for replying. This is what I get:
                        D:\users\abhijat\Windows Scripting>practice.bat
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The filename, directory name, or volume label syntax is incorrect.
                        The full weekday name is ""
                        "C:\Documents and Settings\svc_erd_prd_abacus\Local Settings\Temp;C:\Program Fi
                        es\Downloads\"
                        Press any key to continue . . .

                        Thanks and Regards,
                        Abhijat
                      • foxidrive
                        ... The temp variable has an error on that machine - it is concatenated with another folder. It s a wonder that machine doesn t have other issues. This piece
                        Message 11 of 15 , Oct 13, 2010
                        • 0 Attachment
                          On 13/10/2010 23:42, Abhijat Singh wrote:

                          >> echo The full weekday name is "%dow2%"
                          >> echo "%temp%"
                          >> pause

                          > The full weekday name is ""
                          > "C:\Documents and Settings\svc_erd_prd_abacus\Local Settings\Temp;C:\Program Files\Downloads\"
                          > Press any key to continue . . .


                          The temp variable has an error on that machine - it is concatenated with
                          another folder. It's a wonder that machine doesn't have other issues.

                          This piece should not be there.

                          ;C:\Program Files\Downloads\
                        • Abhijat Singh
                          ... Hi Foxidrive, I got your point. I have now removed ;C: Program Files Downloads from the temp variable and re-ran the original script you gave me. It ran
                          Message 12 of 15 , Oct 13, 2010
                          • 0 Attachment
                            --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
                            >
                            > On 13/10/2010 23:42, Abhijat Singh wrote:
                            >
                            > >> echo The full weekday name is "%dow2%"
                            > >> echo "%temp%"
                            > >> pause
                            >
                            > > The full weekday name is ""
                            > > "C:\Documents and Settings\svc_erd_prd_abacus\Local Settings\Temp;C:\Program Files\Downloads\"
                            > > Press any key to continue . . .
                            >
                            >
                            > The temp variable has an error on that machine - it is concatenated with
                            > another folder. It's a wonder that machine doesn't have other issues.
                            >
                            > This piece should not be there.
                            >
                            > ;C:\Program Files\Downloads\
                            >
                            Hi Foxidrive,
                            I got your point. I have now removed ;C:\Program Files\Downloads\ from the temp variable and re-ran the original script you gave me. It ran error free.

                            Probably, the machine had no other issues till now because its fairly new and its me mostly working on it. With the kind of knowledge I possess (you if not the entire group must have gauged already), I wonder how good an idea is that :-(.
                            Anyways, you are the best!
                            Thanks very much!

                            Kind Regards,
                            Abhijat.
                          Your message has been successfully submitted and would be delivered to recipients shortly.