In one of the legacy application I am working, we are trying to get extracted zip file name through Open3
utility. This is divided into two commands. First command unzip the compressed file and the second one tries to list and grep filename with specific extension. But recently we started encountering error while reading IO buffer.
# unzip with 7z
Open3.capture3("7z", "x", my_zip.path, "-p#{my_pass}", "-o#{tmp_dir}")
# extract file name with .dbf extension
resp, _threads = Open3.pipeline_r(["7z", "-slt", "l", "-p#{my_pass}", my_zip.path], ["grep", "-oP", "(?<=Path = ).+dbf"])
# read IO stream for filename
res_filename = resp.readline.strip
# close stream
# resp.close
at resp.readline.strip
we are encoutering EOFError
. I tried to using ::gets
instead of readline
to avoid EOFError
but it will lead to empty/nil value.
What am I missing? Is there any way to convert IO stream to String object or something like that?
Observed that this is working fine from console but raising exception when job invoked from sidekiq dashboard