execeute gawk from inside ruby script

R

Robert Gilaard

Dear folks,

how can I execeute a awk (or any other script) from
within ruby?

Currently I'm looking into the exec and fork part of
the kernel class but I'm not too sure I'm on the right
trach.

The while loop in the script looks like this in test:

while i<=3D202
location<< "#{i}"
exec "gawk -f fix_creacity.awk $location> defile.txt"

i=3Di+1
location=3D"snapshot"
end

But in the ruby book I have seen that after the ruby
script doesn't get after the exec.=20

But I want to repeat this a few times so what could I
do? Every time the while statement gets executed, I
would like a new output file.

Brdgs
Robert





=09
__________________________________=20
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
 
H

Hugh Sasse

Dear folks,

how can I execeute a awk (or any other script) from
within ruby?

Currently I'm looking into the exec and fork part of
the kernel class but I'm not too sure I'm on the right
trach.

That is a right track, but not the only one.
The while loop in the script looks like this in test:

while i<=202
location<< "#{i}"
exec "gawk -f fix_creacity.awk $location> defile.txt"

i=i+1
location="snapshot"
end

But in the ruby book I have seen that after the ruby
script doesn't get after the exec.

Exec overlays the process with the new one. fork() duplicates the
process then when the child execs you have two different ones.
The parent then wait for the child process to die.
But I want to repeat this a few times so what could I
do? Every time the while statement gets executed, I
would like a new output file.

To save on the apparent complexities of fork and exec, look at
system(), and look at

(0).upto(202) do |i|
%x{gawk -f fix_creacity.awk #{location}#{i}> defile.txt}
end

For more fun look at open and what it says about "| ...", and for
deeper exploration of this realm look at popen.
Brdgs
Robert
Hugh
 
R

Robert Klemme

Hugh said:
That is a right track, but not the only one.

Exec overlays the process with the new one. fork() duplicates the
process then when the child execs you have two different ones.
The parent then wait for the child process to die.

To save on the apparent complexities of fork and exec, look at
system(), and look at

(0).upto(202) do |i|
%x{gawk -f fix_creacity.awk #{location}#{i}> defile.txt}
end

For more fun look at open and what it says about "| ...", and for
deeper exploration of this realm look at popen.

Pretty complete list. I'd like to add "drop (g)awk and do it in Ruby" as
an option though. :)

Kind regards

robert
 
R

Robert Gilaard

Drop gawk, also right:) I have enough to read and
try.
Thanks folks.

Brgds
Robert

--- Robert Klemme said:
=20
Pretty complete list. I'd like to add "drop (g)awk
and do it in Ruby" as
an option though. :)
=20
Kind regards
=20
robert
=20
=20
=20



=09
__________________________________=20
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
 

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

Members online

Forum statistics

Threads
474,186
Messages
2,570,998
Members
47,587
Latest member
JohnetteTa

Latest Threads

Top