From: Aleksei Guzev Date: 2001-07-03T11:01:31+09:00 Subject: [ruby-talk:17173] Re: ` (back tick) on Win32 machines # -----Original Message----- # From: wjl@diggory.ee.byu.edu [mailto:wjl@diggory.ee.byu.edu] # On Behalf Of Wesley James Landaker # Sent: 3 ???? 2001 ?. 2:09 # To: ruby-talk ML # Subject: [ruby-talk:17168] Re: ` (back tick) on Win32 machines # # # Stephan K�mper wrote: # # > Hi all, # > # > I have the following problem both Win2K and Win98SE: # > # > On the Win2K box the following line works fine (and echoes # the name of # > the host) # > # > puts `hostname` # > # > But other commands like "dir", "cd" and the like don't # work... What I # > get is, eg.: # > # > C:\script.rb:1: command not found: dir # > # > with "script.rb" containing the line: # > # > puts `dir # > # > Strangely # > # > puts `dir *` # > # > doesn't complain about missing commands - but doesn't work either # > (that is nothing returned). # > # # The problem is that commands like "dir" and "cd" are not # programs, they are built-in shell commands in command.com. # When you run something with backticks, ruby is using the # stdlib call system(), which executes a program with arguments. # # To get "dir", "cd", and so forth to work, you'll need to do # something like # this: # # puts `command /c dir` # puts `command /c cd\\toast` # # or whatever. # # This isn't really a ruby thing, though. If you were writing # this in C, you'd have to do the same thing when calling the # system() command. # # Nor is it totally a Windows/DOS thing, if you wanted to call # a built-in ksh function in unix in Ruby, you'd probably have # to do something like this if ksh wasn't your default shell: # # puts `ksh -c some command` # # Anyway, I'm writing this from a horrible mail client, so # forgive the strange formatting. (= Hope that you can get it working! On my Win2k `dir` etc work fine. # # -- # Wes Landaker - wjl@mindless.com #