From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-01-22T14:51:30+09:00 Subject: Re: Windows ruby(cygwin version) Command Expansion In article <3c4ccf40_3@news1.prserv.net>, Songsu Yun wrote: >It might be a known problem, but I could not find anything on this in the >news group. >Why does command expansion not work in cygwin version of Windows ruby ? >I get "command not found: dir" message when I use `dir`. >I downloaded version 1.6.5 from www.pragmaticprogrammer.com >It works OK in mswin32 version. >Thanks in advance > > 'dir' is built into the DOS command shell and is not a separate .exe file. You can either do: system("cmd.exe /c dir") #on NT|2000 or system("command.com /c dir") #on Win95|988|ME OR I prefer to redefine 'system' on Windows, like this: if RUBY_PLATFORM =~ /win/i require 'Win32API' def system(command) Win32API.new("crtdll", "system", ['P'], 'L').Call(command) end end That way you don't have to figure out if you're running on NT or 98. Phil