Windows Logfile Archival Script

  • Thread starter Moran, Craig M (BAH)
  • Start date
M

Moran, Craig M (BAH)

I have been doing a lot of automation scripts with Ruby. Since I'm new to
the list, I'm not entirely sure this is the forum for this contribution, but
I wanted to share a handy code snippet. This comes in very handy on Windows
boxes for archiving log files. This will require that WinZip as well as its
command line utilities are installed. Apologies in advance if this isn't
the place to share code. Just let me know. If this code can be done more
elegantly or concisely, please share.
Craig

#/usr/bin/env ruby
require 'ftools'

Dir.chdir("C:/Logfiles")
files = Dir["*.log"]
files.each {|file| system("\"/Program Files/WinZip/WZZIP.EXE\" -m
\"C:\\Logfiles\\Archived.zip\" " +"\"" + file + "\"")}
 
K

Kent S.

By the way, there is a zlib extension which you can use instead of
relying on WinZip installed on your computer.

/kent
 
N

nobu.nokada

Hi,

At Sat, 14 Feb 2004 03:15:14 +0900,
Moran, Craig M (BAH) wrote in [ruby-talk:92804]:
#/usr/bin/env ruby
require 'ftools'

Dir.chdir("C:/Logfiles")
files = Dir["*.log"]
files.each {|file| system("\"/Program Files/WinZip/WZZIP.EXE\" -m
\"C:\\Logfiles\\Archived.zip\" " +"\"" + file + "\"")}

You don't need ftools.rb here.

BTW, why isn't it enough with a batch file, or a shortcut?

@echo off
cd c:\LogFiles
"/Program Files/WinZip/WZZIP.EXE" -m C:\Logfiles\Archived.zip *.log
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top