Communicating with interactive program?
I want to run the command:
svn ls --username xxx
from a script. It requests a password so I have to pass the开发者_JAVA百科 password to it. How I can do this in Ruby?
This is an excellent writeup about using the SVN Ruby bindings:
Using Subversion Ruby Bindings
You should be able to do something like:
require 'open3'
username = "xxx"
password = "xxx"
Open3.popen3("svn ls --username #{username}") do |stdin, stdout, stderr|
stdin.puts(password)
stdin.close
end
This comes straight out of my head, I haven't tested it so it might break in horrible ways. ;)
精彩评论