Code: Select all
set /p first_line=<"C:\FFS\LastSyncs.log"
And from there, you can just search through that string.
Code: Select all
echo %first_line%|findstr /i "successfully" >nul && set subject=[Success] Synchronization completed successfully
Moderator: DosItHelp
Code: Select all
set /p first_line=<"C:\FFS\LastSyncs.log"
Code: Select all
echo %first_line%|findstr /i "successfully" >nul && set subject=[Success] Synchronization completed successfully
Code: Select all
@echo off
set subject=[Failed] The search terms were not found
for /f "delims=" %%x in ('dir "C:\FFS\Logs\" /od /b') do set recent=%%x
findstr /i "successfully nothing" "C:\FFS\Logs\%recent%" >nul && set subject=[Success] Synchronization completed successfully
findstr /i "warnings errors aborted" "C:\FFS\Logs\%recent%" >nul && set subject=[Failed] Synchronization completed with errors
"C:\FFS\mailsend.exe" +cc +bc -v -smtp smtp.gmail.com -ssl -port 465 -auth -user EMAIL -pass PASSWORD -f EMAIL -to EMAIL -cc EMAIL -bc EMAIL -sub "FFS_COMPANYNAME/SOURCE-FOLDER_DESTINATION-FOLDER_WHEN: %time%, %date% - %subject%" -attach "C:\FFS\Logs\%recent%"
Code: Select all
@echo off
timeout /t 5
set subject=[Failed] The search terms were not found
set /p first_line=<"C:\FFS\LastSyncs.log"
echo %first_line%|findstr /i "successfully" >nul && set subject=[Success] Synchronization completed successfully
echo %first_line%|findstr /i /c:"Nothing to synchronize" >nul && set subject=[Success] Nothing to synchronize
echo %first_line%|findstr /i "warnings errors aborted" >nul && set subject=[Failed] Synchronization completed with errors
"C:\FFS\mailsend.exe" +cc +bc -v -smtp smtp.gmail.com -ssl -port 465 -auth -user EMAIL -pass PASSWORD -f EMAIL -to EMAIL -cc EMAIL -bc EMAIL -sub "FFS_COMPANYNAME/SOURCE-FOLDER_DESTINATION-FOLDER_WHEN: %time%, %date% - %subject%" -attach "C:\FFS\LastSyncs.log"
Code: Select all
_____________________________________________________________________
|2/14/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Nothing to synchronize
eahm wrote:Sorry it's the second line not the first. Is there a way to make it work with that? Thanks.Code: Select all
_____________________________________________________________________
|2/14/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Nothing to synchronize
Code: Select all
(
set /p ignore=
set /p first_line=
)<"C:\FFS\LastSyncs.log"
Code: Select all
@echo off
timeout /t 5
set subject=[Failed] The search terms were not found
(
set /p ignore=
set /p first_line=
)<"C:\FFS\LastSyncs.log"
echo %first_line%|findstr /i "successfully" >nul && set subject=[Success] Synchronization completed successfully
echo %first_line%|findstr /i /c:"Nothing to synchronize" >nul && set subject=[Success] Nothing to synchronize
echo %first_line%|findstr /i "warnings errors aborted" >nul && set subject=[Failed] Synchronization completed with errors
"C:\FFS\mailsend.exe" +cc +bc -v -smtp smtp.gmail.com -ssl -port 465 -auth -user EMAIL -pass PASSWORD -f EMAIL -to EMAIL -cc EMAIL -bc EMAIL -sub "FFS_COMPANYNAME/SOURCE-FOLDER_DESTINATION-FOLDER_WHEN: %time%, %date% - %subject%" -attach "C:\FFS\LastSyncs.log"
eahm wrote:Something is not working, even if I add pause at the end I don't see the bat starting at all.
Code: Select all
C:\FFS>(
set /p ignore=
set /p first_line=
) 0<"C:\FFS\LastSyncs.log"
C:\FFS>echo | 2/19/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Synchronization co
mpleted successfully | findstr /i "successfully nothing" 1>nul && set subjec
t=[Success] Synchronization completed successfully
'2' is not recognized as an internal or external command,
operable program or batch file.
C:\FFS>
eahm wrote:Code: Select all
C:\FFS>(
set /p ignore=
set /p first_line=
) 0<"C:\FFS\LastSyncs.log"
C:\FFS>echo | 2/19/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Synchronization co
mpleted successfully | findstr /i "successfully nothing" 1>nul && set subjec
t=[Success] Synchronization completed successfully
'2' is not recognized as an internal or external command,
operable program or batch file.
C:\FFS>
Code: Select all
C:\FFS>mailalert.bat
'2' is not recognized as an internal or external command,
operable program or batch file.
C:\FFS>
Code: Select all
H:\>echo | 2/19/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Synchronization completed successfully | findstr /i "successfully nothing"
'2' is not recognized as an internal or external command,
operable program or batch file.
H:\>echo " | 2/19/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Synchronization completed successfully" | findstr /i "successfully nothing"
" | 2/19/2015 - [Data1]-Utils_[iTM64GBPat]-Utils: Synchronization completed successfully"
eahm wrote:I am sure I already did but I will try again with his exact version.
Exact version:Code: Select all
C:\FFS>mailalert.bat
'2' is not recognized as an internal or external command,
operable program or batch file.
C:\FFS>
eahm wrote:I have no idea what Squashman did with that reply...