From: Mark Wilson Date: 2003-08-26T05:02:05+09:00 Subject: Re: Ruby launching system apps? 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? > > use Shell.new? I've found that when you have a program that makes use of UNIX commands within various classes and methods that system and `` calls can lead to synchronization problems -- and that such problems can be solved by using the Shell#transact method. Here's an example: class Document Shell.def_system_command("lynx") attr_reader :path def initialize(path) @path = path end def html_to_text_stdout # the following line is needed because @path is not in the scope of the transact block below path = @path html_to_text = String.new shell = Shell.new shell.transact do html_to_text = (shell.lynx("-dump", path)).to_s end html_to_text end end I agree with Gennady that you will frequently be better off using native Ruby classes and methods for many things, particularly in-memory string manipulation, even if comparable tools are available through a Unix command. Regards, Mark