V
V
Vayladion Gognazdiak2020-02-03 17:59:14
ruby
Vayladion Gognazdiak, 2020-02-03 17:59:14

How to send each array element to pipeline?

Good day, Ruby.
There is a file which is read through readlines. Further there are some manipulations with these lines.
And then the string must be sent to the minio store via the pipeline.

The problem is that the pipeline to the store rises by launching the binary.

require 'shell'
shell.system("minio-cmd pipe minio-server/my_store/long_test.txt")


Actually option N1, but it does not fit, since the pipeline will be closed after sending the first line.
require 'shell'
shell = Shell.new
pipeline = shell.system("minio-cmd pipe minio-server/my_store/long_test.txt")

File.readlines('data.txt').each do |line|
  shell.echo(line) | pipeline
end


Option N2, also unfortunately non-working
def pipe_it
  File.readlines('data.txt').each do |line|
   .......
   .......
   yield(line)
  end
end
pipe_it{|x| shell.echo("#{x}")} | pipeline


Where to dig? What implementation options are possible without the use of additional gems?
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kaasmith, 2020-02-20
@kaasmith

And if you create a shell for each line, i.e. inside the file read block?

File.readlines('data.txt').each do |line|
  shell.system("minio-cmd pipe minio-server/my_store/long_test.txt | #{line}")
end

I haven't tested it, but it should work within the block.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question