2013-02-14 72 views
1

我建立了一个基本的配置/ deploy.rb文件与任务:Capistrano的伪终端(PTY)不工作

task :blah do 
    run ". ~/blah.sh" 
end 

和服务器上,该blah.sh文件只是提示输入:

while true; do 
    read -p "Say something: " blah 
done 

Capistrano连接到我的服务器就好了,正常的命令也可以。当我运行cap blah它会提示我输入,但无论我输入什么,它都不会发送回服务器。输出如下:

* 2013-02-13 19:12:36 executing `blah' 
    * executing ". ~/blah.sh" 
    servers: ["192.81.214.76"] 
    [192.81.214.76] executing command 
** [out :: 192.81.214.76] Say something: 

而且无论我输入什么,它都不会响应。

注意我并设置default_run_options[:pty] = true

我甚至不知道这是我的本地设置或服务器出现问题。有任何想法吗?

+0

好像Capistrano的是不是该建:http://comments.gmane.org/gmane.comp.lang.ruby.capistrano 。一般/ 5038 – foobar 2013-02-14 02:24:06

回答

0

而不是使用sh脚本的,用耙子任务(这是我做什么,反正)

namespace :interact do 
    task :say_something do 
     system("read -p 'Say something: ' blah && echo $blah") 
    end 
end 

然后建立一个运行命令,可以处理通信来回远程一个Capistrano的任务服务器

namespace :interact do 
    task :say_something do 
     run "cd #{deploy_to}/current && #{rake} interact:say_something", :pty => true do |ch, stream, data| 
      if data =~ /Say something:/ 
       # prompt, and then send the response to the remote process 
       ch.send_data(Capistrano::CLI.password_prompt("Say something (to the remote server): ") + "\n") 
      else 
       # use the default handler for all other text 
       Capistrano::Configuration.default_io_proc.call(ch, stream, data) 
      end 
     end 
    end 
end 

由于http://comments.gmane.org/gmane.comp.lang.ruby.capistrano.general/5038上这是基于