From: Mark Wilson Date: 2003-08-26T06:59:19+09:00 Subject: Re: Ruby launching system apps? On Monday, August 25, 2003, at 05:05 PM, Mark J. Reed wrote: > On Monday, August 25, 2003, at 01:25 PM, Dan wrote: >> I have a UNIX machine and I want a ruby app that can launch UNIX >> commands like awk or sed...how would I implement this? > > The Shell module lets you invoke UNIX commands, but bear in mind > that doing so is inefficient, Avoid premature optimization. If the inefficiency is a problem, implement in Ruby. If it is still a problem, extend Ruby with C. > not portable to non-UNIX machines, True. The universe of Unix machines is pretty large (including Mac OS X). I don't know about Windows with cygwin. > and likely to cause thread synchronization issues. The Shell#transact method will handle synchronization. > Ruby itself can > do everything awk and sed can do without having to resort to > running external programs. > [snip] True. 'awk' and 'sed' are the least likely candidates, in my opinion, for wrapping in the Shell class. However, if you have a shell script with functionality you want to use in a Ruby program that you don't want to spend the time reimplementing in Ruby, the Shell class may be your best bet, at least initially. Regards, Mark