Announcement

Collapse
No announcement yet.

Script verifying the RAR file has been created and completed

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script verifying the RAR file has been created and completed

    I have an issue on a script. I have a script that every day it compress a folder and name it the date.rar example 01042011.rar. Now I need to include in this script that it will check that the rar has been done and send me an email. Is this possible please. Note the script is running in .bat, but the email script can be done in VB and I will call it from the batch. Let me know.

  • #2
    Re: Script to send email

    suggests that it is, indeed, possible
    http://www.google.co.uk/search?hl=en...meta=&aq=f&oq=
    It may even be possible within a batch file:
    http://www.google.co.uk/search?hl=en...meta=&aq=f&oq=
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Script to send email

      Hi Ossian, those I read the issue is how to make it to confirm that the file has been created. I have something like the below, but I need it to be able to confirm on the rar file that will be created on a daily basis.

      set mailer=c:\script\blat.exe
      set errorlog=c:\script\logsnotfound.txt
      set to01= [email protected]
      set from= [email protected]
      set subject="Missing Backup Files"
      set mailserver=exchange server
      del %errorlog%
      echo Log Parsing Process - Missing Files: >> %errorlog%
      echo ' >> %errorlog%
      for /f %%l in (%loglist%) do @IF NOT EXIST %backuppath%\%%l echo %backuppath%\%%l >> %errorlog%
      %mailer% %errorlog% -t %to01% -f %from% -s %subject% -server exchangeserver

      Comment


      • #4
        Re: Script to send email

        Ah -- I thought from your original post it was the emailing that was the issue

        So you are wanting to confirm only that the RAR file exists, or is it more complex?

        Roughly:
        DIR <path and name of file>
        Check output for string "File Not Found" then email subject = "Error"
        Else email subject = "Success"

        VSScript would be easier for this:
        http://www.google.co.uk/search?hl=en...meta=&aq=f&oq=
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Script to send email

          The issue it that the filename changes daily example today 04012011.rar and tomorrow 05012011.rar

          Comment


          • #6
            Re: Script to send email

            Yes, but you can get that information easily enough
            In a batch file, try echo %date%
            (not quite the correct format but with a little editing...)
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd
            Scotland

            ** Remember to give credit where credit is due and leave reputation points where appropriate **

            Comment


            • #7
              Re: Script to send email

              I'm stuck.

              Is there a way the when the RAR is create the script continues like this:

              If RAR with date today is in this directory d:\home then send email with success, if not send it with fail.

              Comment


              • #8
                Re: Script to send email

                Here is a VB script to do something very similar:
                http://michaelkizer.com/Blog/tabid/1...-VBScript.aspx
                You should have little difficulty adapting it -- just treat it as a learning experience

                For the dates, something here will work:
                http://www.google.co.uk/search?hl=en...meta=&aq=f&oq=
                Last edited by Ossian; 4th January 2011, 16:28.
                Tom Jones
                MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
                PhD, MSc, FIAP, MIITT
                IT Trainer / Consultant
                Ossian Ltd
                Scotland

                ** Remember to give credit where credit is due and leave reputation points where appropriate **

                Comment


                • #9
                  Re: Script to send email

                  Originally posted by rbezzina View Post
                  I'm stuck.

                  Is there a way the when the RAR is create the script continues like this:

                  If RAR with date today is in this directory d:\home then send email with success, if not send it with fail.
                  I assume when the RAR file is completed the RAR-application stops?

                  If that is the case then in the batch use a goto:label to create a loop - within the loop perform a TASKLIST.exe statement piped to a FIND.exe condition.

                  What is the name of the process? so I can show what I mean.


                  \Rems

                  This posting is provided "AS IS" with no warranties, and confers no rights.

                  __________________

                  ** Remember to give credit where credit's due **
                  and leave Reputation Points for meaningful posts

                  Comment


                  • #10
                    Re: Script to send email

                    Hi Rems, the process is RAR.exe

                    I have this script:

                    set log=C:\script\apache_backup_script.log
                    set backuppath=D:\TestBackup1\RAR
                    set backupcontent=D:\TestBackup1\DATA
                    set loglist=c:\script\logchecklist.txt
                    set servername=Server_tomcat
                    set rar=C:\script\rar.exe

                    REM ================================================== =====
                    REM Delete old files under D:\home\ftp\backup\webdeck\Apache\RAR
                    REM ================================================== =====
                    del D:\TestBackup1\RAR\*.* /Q >> %log%
                    REM ======================
                    REM D:\Program Files\Apache Software Foundation\Tomcat 5.5\conf backup
                    REM ======================
                    mkdir D:\TestBackup1\DATA\conf
                    xcopy "D:\TestBackup\Conf" D:\TestBackup1\DATA\conf /A /I /E /Y /H /K /C /V >> %log%

                    REM ======================
                    REM Compress Contents
                    REM ======================

                    %rar% m -r -ag-YYYYMMDD %backuppath%\%servername%_bkup.rar %backupcontent%\* >> %log%
                    xcopy D:\TestBackup1\RAR\*.rar E:\TestBackup2\RAR\


                    Now what I need is that when the RAR is created I want to be notified.

                    Comment


                    • #11
                      Re: Script verifying the RAR file has been created and completed

                      Give this a try,
                      Code:
                      <...cut...>
                      
                      REM ======================
                      REM Compress Contents
                      REM ======================
                      
                      call:TODAY
                      Set "$archive=%backuppath%\%TODAY%_%servername%_bkup.rar"
                      
                      %rar% m -r "%$archive%" "%backupcontent%\*" >>"%log%"
                      
                         If %errorlevel% EQU 255 goto :rar_exit_255
                         If %errorlevel% EQU 9 goto :rar_exit_9
                         If %errorlevel% EQU 8 goto :rar_exit_8
                         If %errorlevel% EQU 7 goto :rar_exit_7
                         If %errorlevel% EQU 6 goto :rar_exit_6
                         If %errorlevel% EQU 5 goto :rar_exit_5
                         If %errorlevel% EQU 4 goto :rar_exit_4
                         If %errorlevel% EQU 3 goto :rar_exit_3
                         If %errorlevel% EQU 2 goto :rar_exit_2
                         If %errorlevel% EQU 1 goto :rar_exit_1
                         If %errorlevel% EQU 0 goto :rar_exit_0
                      
                      xcopy "D:\TestBackup1\RAR\*.rar" "E:\TestBackup2\RAR\"
                      
                      If exist "%$archive%" (
                          echo send message 'success'
                          ) ELSE (
                          echo send message 'failed'
                          )
                      
                      
                      goto:EOS  + + + subroutines + + +
                       :TODAY sub
                         setlocal & Set "r=%~0"
                         for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do (
                           for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do (
                           (set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yyyy=%%p)))
                         endlocal & Set %r:~1%=%yyyy%%mm%%dd%
                         exit /b 0
                      
                       :rar_exit_255 "USER BREAK"
                         echo User stopped the process
                         exit /b 0
                       :rar_exit_9 "CREATE ERROR"
                         echo Create file error
                         exit /b 0
                       :rar_exit_8 "MEMORY ERROR"
                         echo Not enough memory for operation
                         exit /b 0
                       :rar_exit_7 "USER ERROR"
                         echo Command line option error
                         exit /b 0
                       :rar_exit_6 "OPEN ERROR"
                         echo Open file error
                         exit /b 0
                       :rar_exit_5 "WRITE ERROR"
                         echo Write to disk error
                         exit /b 0
                       :rar_exit_4 "LOCKED ARCHIVE"
                         echo Attempt to modify an archive previously locked by the 'k' command
                         exit /b 0
                       :rar_exit_3 "CRC ERROR"
                         echo A CRC error occurred when unpacking
                         exit /b 0
                       :rar_exit_2 "FATAL ERROR"
                         echo A fatal error occurred
                         exit /b 0
                       :rar_exit_1 "WARNING"
                         echo Non fatal error(s) occurred
                         exit /b 0
                       :rar_exit_0 "SUCCESS"
                         echo Successful operation (User exit)
                         exit /b 0
                      :EOS - End Of Subroutines -

                      \Rems
                      Last edited by Rems; 14th January 2011, 15:28.

                      This posting is provided "AS IS" with no warranties, and confers no rights.

                      __________________

                      ** Remember to give credit where credit's due **
                      and leave Reputation Points for meaningful posts

                      Comment

                      Working...
                      X