Ruby launching system apps?

D

Dan

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?
 
G

Gennady

The simplest way is to use "system" or `` (you can use Shell too, of
course). ôhe best way is to implement in Ruby all you do with awk and sed,
as it has (almost) everything those utilities offer.

Before I found Ruby, my favorite combination was sh/awk/sed. Now I do
everything of that kind in Ruby, however knowledge and long experience with
those utilities help me a lot, especially with regexp stuff.

Gennady.

----- Original Message -----
From: "Dan" <[email protected]>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <[email protected]>
Sent: Monday, August 25, 2003 10:25 AM
Subject: Ruby launching system apps?
 
M

mgarriss

Dan said:
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?

`cat some_file` # returns string of stdout
system 'cat some_file' # returns success (true/false)
exec 'cat some_file' # replaces current process
popen 'cat some_file' # returns IO object connected to stdin and stdout

require 'open3'
Open3.popen3 'cat some_file' # returns [in,out,err]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,109
Messages
2,570,671
Members
47,261
Latest member
Hendra45

Latest Threads

Top