I'm using IO.popen
to run a curl
command (octet stream POST). I copy the command and run it on a command line and it works. Running it in Ruby with popen
, however, causes the stream to end unexpectedly on my server and the Ruby script just hangs, with curl
endlessly running.
Here's what I'm doing:
curl = "curl "
curl += "--cookie \"JSESSIONID=#{@sessionid}\" "
curl += "-H \"Content-type:application/octet-stream\" "
curl += "-X POST "
curl += "-o \"#{responseFile}\" "
curl += "--data-binary \"@#{filename}\" "
curl += "\"#{url}\""
puts "command: #{curl}"
IO.popen(curl, "r") { |out|
out.readlines
}
# Script never makes it to here
I must be doing something silly. What is it?
I am using Ruby 1.8.6