Skip to content

Commit

Permalink
Merge pull request #2 from shazic/Remove-Headers
Browse files Browse the repository at this point in the history
Remove headers
  • Loading branch information
shazic authored Jul 13, 2017
2 parents 3361751 + c5ce95d commit 5c85e7f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following needs to be completed before using this cmd:
2. AWS CLI and gzip must be installed.
3. The path where _aws.exe_ and _gzip.exe_ are installed must be included in the PATH system variable.
4. AWS configure must be run and the access keys and region must be set.
5. Copy the files _getcflog.bat_, _reseterrorlevel.bat_ and _settimestamp.bat_ from this git to the folder where you would like to generate the CloudFront log file.
5. Copy the files from the _dos_ folder of this git to the folder where you would like to generate the CloudFront log file.

___

Expand Down
34 changes: 25 additions & 9 deletions dos/getcflog.bat
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
@rem $$ $$
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

@echo off

@set errormessage=
@call reseterrorlevel

Expand Down Expand Up @@ -101,7 +103,9 @@
@if %ERRORLEVEL% NEQ 0 set errormessage="Problem executing gzip. "
@if %ERRORLEVEL% NEQ 0 goto errormsg1

@copy *.log cf-logs.%ts%.txt
@set tempfile=cf-logs.temp.%ts%.txt

@copy *.log %tempfile%
@if %ERRORLEVEL% NEQ 0 set errormessage="Unable to copy files. "
@if %ERRORLEVEL% NEQ 0 goto errormsg1

Expand All @@ -112,23 +116,35 @@
@cd..


@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
@rem $$ OUTPUT $$
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

@move %tempfolder%\cf-logs.%ts%.txt cf-logs.%ts%.txt
@move %tempfolder%\%tempfile% %tempfile%
@if %ERRORLEVEL% NEQ 0 set errormessage="Unable to move files. "
@if %ERRORLEVEL% NEQ 0 goto errormsg2

@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


@rem delete the temporary folder.
@rem ----------------------------
@rmdir %tempfolder%
@if %ERRORLEVEL% NEQ 0 set errormessage="Unable to delete directory. "
@if %ERRORLEVEL% NEQ 0 goto errormsg


@set ofile=cf-logs.%ts%.txt

@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
@rem $$ OUTPUT $$
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

@call rmvhdrs %tempfile% %ofile%
@if %ERRORLEVEL% NEQ 0 set errormessage="Unable to generate output file. "
@if %ERRORLEVEL% NEQ 0 goto errormsg

@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

@del %tempfile%
@if %ERRORLEVEL% NEQ 0 set errormessage="Unable to delete file. "
@if %ERRORLEVEL% NEQ 0 goto errormsg



@rem job finished. Time to rest!
@rem ----------------------------
goto endofjob
Expand Down
2 changes: 1 addition & 1 deletion dos/reseterrorlevel.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
@rem $$ $$
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

exit /b 0
@exit /b 0
35 changes: 35 additions & 0 deletions dos/rmvhdrs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
@rem $$ $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ PURPOSE $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ $$
@rem $$ REMOVES HEADER RECORDS FROM THE CONSOLIDATED LOG FILE. $$
@rem $$ THIS BAT FILE REMOVES THE RECORDS THAT STARTS WITH A # $$
@rem $$ SYMBOL AT THE FIRST POSITION. $$
@rem $$ $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ SYNTAX $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ $$
@rem $$ RMVHDRS INPUT_CONSOLIDATED_LOG_FILE OUTPUT $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ OUTPUT $$
@rem $$ ---------------------------------------------------------- $$
@rem $$ $$
@rem $$ FILE: $$
@rem $$ THE CONTENT IS SAME AS THE INPUT FILE, WITHOUT $$
@rem $$ THE HEADER RECORDS. $$
@rem $$ $$
@rem $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

@echo off
SETLOCAL DisableDelayedExpansion
FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ %1"`) do (
set "var=%%a"
SETLOCAL EnableDelayedExpansion
set "var=!var:*:=!"
set "frstsmbl=!var:~0,1!"
if "!frstsmbl!" NEQ "#" echo(!var! >> %2
ENDLOCAL
)

1 comment on commit 5c85e7f

@shazic
Copy link
Owner Author

@shazic shazic commented on 5c85e7f Jul 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completes the Enhancement Issue #1

Please sign in to comment.