In my project there is one script that returns the list of products which I have to display in a table.
To store the input of the script I used IO.popen
:
@device_list = []
IO.popen("device list").each do |device|
@device_list << device
end
device list
is the command that will give me the product list.
I return the @device_list
array to my view for displaying by iterating it.
When I run it I got an error:
Errno::ENOMEM (Cannot allocate memory):
for IO.popen
I have on another script device status
that returns only true and false but I got the same error:
def check_status(device_id)
@stat = system("status device_id")
if @stat == true
"sold"
else
"not sold"
end
end
What should I do?