Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect a process ending with Ruby open3

Tags:

ruby

If I run open with:

input, output,error = Open3.popen3 "nikto -host someip -port 80 -output xml"

How can I detect if nikto is done? It takes a while for the scan to complete.

If something goes wrong, I suppose I have to periodically check error to see if anything that been written?

Is there any decent docs that exist for open3? No, the ruby-docs are nowhere near decent.

like image 573
user370731 Avatar asked Dec 27 '25 16:12

user370731


1 Answers

input, output, error = Open3.popen3 "nikto -host someip -port 80 -output xml"

if select([output], nil, nil, 0.1) and output.eof?
  # process exited and doesn't have output queued.
else
  # still running or has output not read yet.
end

Also, here is some good documentation I found by googling: http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/open3/rdoc/index.html

like image 100
Adrian Avatar answered Dec 31 '25 19:12

Adrian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!