From: Gennady Bystritsky Date: 2006-05-03T01:30:59+09:00 Subject: Re: Calling Shell Scripts from Ruby ? > -----Original Message----- > From: list-bounce@example.com > [mailto:list-bounce@example.com] On Behalf Of Dinesh Umanath > Sent: Tuesday, May 02, 2006 9:18 > To: ruby-talk ML > Subject: Calling Shell Scripts from Ruby ? > > Hi all, > > I have two questions > > 1)Is it possible to call "Shell Scripts" from ruby? Say if i > have a shell sciprt named "test.sh", how can i call this from > ruby? Also if i can call like that,is it possible to get the > output of that script passed back to ruby? Shell scripts fall into "any Unix command" category, so keep on reading. > > 2)How can i call any "Unix command" residing from a ruby program?? 1. Backquotes result = `test.sh` 2. exec(), fork/exec exec 'test.sh' === Process.wait fork { exec 'test.sh' } 3. popen(), popen3(), etc. IO.popen('test.sh') { |_io| _io.readlines() } 4. Good old system() system('test.sh') Read about all those facilities in the documentation to get the most out of it. Gennady. > > > Thank You > Dinesh > > -- > Posted via http://www.ruby-forum.com/. > >