开发者

Communicating with interactive program?

开发者 https://www.devze.com 2023-04-02 07:43 出处:网络
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 abo

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. ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消