Aleksei Guzev wrote: > ----- 8< snipped a considerable amount of text from various postings... > # Stephan KçÎper wrote: > # > 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` > # > > # 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. Hmmm. I'm still a bit (a byte to be true) puzzled. That's because it works as (I) expected with Perl, eg print `dir` works fine in the Perl flavour I use on both Win2K and Win98. And I wished it'd be the same behaviour in Ruby. That would make migrating form Win98 to Win2K (or vice versa) a lot more easy (No need to detect the Win flavour and then chose cmd.exe or command.com respectively.) > # 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` OK. tried that, unfortunately 'dir' on its own work fine but beware if you (read: I) add some args to dir ('*' or the like). No useful output. > # 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` I see. But then: How does Perl do it? (Note that I do not prefer Perl...) > # Anyway, I'm writing this from a horrible mail client, so > # forgive the strange formatting. (= Hope that you can get it working! Looks OK for me. Didn't get it to work up to now though. > > On my Win2k `dir` etc work fine. > What Ruby version / installation do you use? The one from the pragmatic programmers perhaps? In the end: Could it be a user error? Am I probably doing something terribly wrong? If so, what could it be? Any help in sight? Thanks again & happy rubying! Stephan