Professional Web Applications Themes

Windows Logfile Archival Script - Ruby

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 ...

  1. #1

    Default Windows Logfile Archival Script

    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 + "\"")}


    Moran, Guest

  2. #2

    Default Re: Windows Logfile Archival Script

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

    /kent

    Moran, Craig M (BAH) wrote: 
    Kent Guest

  3. #3

    Default Re: Windows Logfile Archival Script

    On Fri, 2004-02-13 at 13:15, Moran, Craig M (BAH) wrote: 

    Hi Craig -

    That's cool; you could also put it here:

    http://rubyforge.org/snippet/browse.php?by=cat&cat=1

    Yours,

    tom



    Tom Guest

  4. #4

    Default Re: Windows Logfile Archival Script

    Hi,

    At Sat, 14 Feb 2004 03:15:14 +0900,
    Moran, Craig M (BAH) wrote in [ruby-talk:92804]: 

    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


    --
    Nobu Nakada


    nobu.nokada@softhome.net Guest

  5. #5

    Default Re: Windows Logfile Archival Script

    Hi,

    At Mon, 16 Feb 2004 23:15:36 +0900,
    Moran, Craig M (BAH) wrote in [ruby-talk:92981]: 

    At least, you wouldn't need to iterate for each files in ruby,
    many zip tools accept multiple files at once.

    ZIP = "/Program Files/WinZip/WZZIP.EXE"
    Archive = "C:\\Logfiles\\Archived.zip"
    system(ZIP, "-m", Archive, *Dir["*.log"])

    And Dir.chdir is a builtin method, which calls the underlying
    system call.

    --
    Nobu Nakada


    nobu.nokada@softhome.net Guest

Similar Threads

  1. Archival of Live streams
    By dl0haus in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: November 26th, 09:35 PM
  2. ZIP'd TIFFs vs. PSD for archival storage
    By Rene_Walling@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 2
    Last Post: February 10th, 02:34 AM
  3. yse logfile and block ms-script-hacker
    By udoline in forum Linux / Unix Administration
    Replies: 0
    Last Post: February 1st, 03:57 PM
  4. Archival and preservation of negatives
    By Andrei in forum Photography
    Replies: 5
    Last Post: December 15th, 03:12 AM
  5. Archival photo quality paper
    By Jeff Furber in forum Photography
    Replies: 6
    Last Post: July 12th, 10:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139