*.rb not running on Windows any more

Discussion in 'Ruby' started by Phrogz, Jul 20, 2006.

  1. Phrogz

    Phrogz Guest

    At work, I installed 1.8.2 from the one-click.
    I wrote a handy utility named "findfile.rb", and put it in my
    windows\system32 directory.
    I was happy, because I could open any cmd window and type "findfile
    ...." and my ruby script would kick the crap out of Windows' built-in
    search features.

    But then I installed 1.8.4 from the one-click.
    Now, when I type "findfile ..." in a command window, Windows rudely
    informs me:
    "'findfile' is not recognized as an internal or external command,
    operable program or batch file."

    The findfile.rb file is still in the same spot.
    Ruby was installed in the same spot.
    I've tried associating *.rb with c:\ruby\bin\ruby.exe and
    c:\ruby\bin\rubyw.exe, but to no avail.

    Who can help me in my quest to continue to kick the crap out of
    Windows' built-in search?

    (For those interested, following is my hack script. It was originally
    written to allow regexp filename searching, and was later expanded to
    allow regexp content searching, too.)

    require 'rubygems'
    require_gem 'Usage'
    usage = Usage.new "name_regexp [content_regexp]"

    class Dir
    def self.crawl( path, max_depth=nil, depth=0, &block )
    return if max_depth && depth > max_depth
    begin
    if File.directory?( path )
    files = Dir.entries( path ).select{ |f| f[0,1]!='.' }
    unless files.empty?
    files.collect!{ |file_path|
    Dir.crawl( path+'/'+file_path, max_depth, depth+1, &block )
    }.flatten!
    end
    return files
    elsif File.file?( path )
    yield( path, depth )
    end
    rescue SystemCallError => the_error
    warn "ERROR: #{the_error}"
    end
    end

    end

    start_time = Time.new
    name_match = Regexp.new( usage.name_regexp, true )
    content_match = usage.content_regexp && Regexp.new(
    ".{0,10}#{usage.content_regexp}.+", true )

    matching_count = 0
    Dir.crawl( '.', usage.max_depth ){ |file_path, depth|
    if File.split( file_path )[ 1 ] =~ name_match
    if content_match
    if IO.read( file_path ) =~ content_match
    puts file_path," #{$~}"," "
    matching_count += 1
    end
    else
    puts file_path
    matching_count += 1
    end
    end
    }
    end_time = Time.new
    puts "(Found #{matching_count} files in #{end_time-start_time} seconds)"
     
    Phrogz, Jul 20, 2006
    #1
    1. Advertising

  2. Phrogz

    Ben Zealley Guest


    > But then I installed 1.8.4 from the one-click.
    > Now, when I type "findfile ..." in a command window, Windows rudely
    > informs me:
    > "'findfile' is not recognized as an internal or external command,
    > operable program or batch file."
    >
    > The findfile.rb file is still in the same spot.
    > Ruby was installed in the same spot.
    > I've tried associating *.rb with c:\ruby\bin\ruby.exe and
    > c:\ruby\bin\rubyw.exe, but to no avail.
    >
    > Who can help me in my quest to continue to kick the crap out of
    > Windows' built-in search?


    I'm guessing a bit here, but the problem might lie in the Path or
    PATHEXT environment variables, rather than Explorer's file associations
    (which I don't think cmd even knows about) - one or the other may have
    been modified by the 1.8.4 one-click? I'm probably embarrassingly wrong
    though, so hopefully someone else can be more helpful...

    --
    Ben
     
    Ben Zealley, Jul 20, 2006
    #2
    1. Advertising

  3. Phrogz

    Phrogz Guest

    Ben Zealley wrote:
    > I'm guessing a bit here, but the problem might lie in the Path or
    > PATHEXT environment variables


    PATHEXT it was, thanks!

    Now I can go back to pwning Microsoft and usage this computer in a
    moderately more reasonable fastion.
     
    Phrogz, Jul 20, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lauchlan M
    Replies:
    5
    Views:
    3,399
    Lauchlan M
    Jun 3, 2004
  2. Michael
    Replies:
    4
    Views:
    418
    Matt Hammond
    Jun 26, 2006
  3. Stef Mientki
    Replies:
    0
    Views:
    350
    Stef Mientki
    Nov 1, 2009
  4. Robert Klemme

    With a Ruby Yell: more, more more!

    Robert Klemme, Sep 28, 2005, in forum: Ruby
    Replies:
    5
    Views:
    218
    Jeff Wood
    Sep 29, 2005
  5. hara
    Replies:
    3
    Views:
    105
    Brian McCauley
    May 12, 2006
Loading...

Share This Page