From: Ronald Fischer Date: 2007-06-22T18:12:18+09:00 Subject: Re: Calling Ruby from within Ruby under Windows > At Thu, 21 Jun 2007 20:56:49 +0900, > Ronald Fischer wrote in [ruby-talk:256378]: > > I get the error message: > > > > H:/tmp/x.rb:1:in ``': Exec format error - t2.rb (Errno::ENOEXEC) > > from H:/tmp/x.rb:1 > > > > Is this a bug or intended behaviour? > > Not a bug. Cmd.exe uses ShellExecute or similar, which see the > association. You may want to say, "then use it in ruby too", > but no. It doesn't handle redirection. > > Once I had tried changing to see the association, it was very > tiresome and others didn't seem to like to merge it. I understand. In any case, maybe it makes sense to look at the issue from a completely different point of view: What is the best way to call an external program (maybe written in Perl, Ruby, Python or whatever) from within Ruby, under the conditions that - The resulting "multi-language" application should be easy to port between Windows and Unix/Linux, and - The program should be looked up using PATH. On Unix, it is easy of course, because both can be handled by the shell via which the external program can be invoked. On Windows, this seems to work in a similar way if I invoke a external program from the Windows command line. When doing it from Ruby, I would have to manually search the PATH for a matching program, then determine, which language the program is (Ruby, Perl,...), and execute that language interpreter, handing it as argument the path of the program. This certainly can be done, but I wonder whether this is not a sufficiently general problem, that it should make it somehow into Ruby. I can understand that you don't want to go this "magic" into the default versions of %x(...) and system(...), but maybe it should be offered as an option, for instance controlled via some switch? Ronald