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<=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.
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
···
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
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
···
On Thu, 3 Nov 2005, Robert Gilaard wrote:
Drop gawk, also right:-) I have enough to read and
try.
Thanks folks.
Brgds
Robert
···
--- Robert Klemme <bob.news@gmx.net> wrote:
Hugh Sasse wrote:
> On Thu, 3 Nov 2005, Robert Gilaard wrote:
>
>> 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.
Pretty complete list. I'd like to add "drop (g)awk
and do it in Ruby" as
an option though. 
Kind regards
robert
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.