Trying to write a Ruby command line interface. However when the program exits, then will the message appear.
Here is my program:
require 'open-uri'
url = ARGV[0]
if url.nil?
abort "no URL provided"
end
begin
puts open(url)
rescue => e
abort e.message
end
I get the following
> ruby -Ilib bin/command http://iservice.ltn.com.tw/2014/specials/nonukes/news.php?rno=1&type=l&no=998123
[1] 8642
[2] 8643
[2]+ Done type=l
> #<StringIO:0x007fdf96ac82f8>
[1]+ Done ruby -Ilib bin/command http://iservice.ltn.com.tw/2014/specials/nonukes/news.php?rno=1&type=l&no=998123
>
As you can see, some strange lines appears first such as [1] 8642
, then the program exits. And the after a second the shell prints out #<StringIO:0x007fdf96ac82f8>
, and hangs there.
I then have to press enter in order to exit the program.
UPDATE This seems only happens to some URL such the the one listed in the example.
Why does my program exits then print the result, and the hangs? What are the strange log messages?
I guess you passing a URL with query string.
Quote your URL in command line