ローカルマシンのffmpegを模倣するスクリプトがあります。リモートマシンにコマンドを送信して実行し、結果を返します。私はリアルタイムにローカルユーザーへのCMDの出力を表示したいシェルコマンドからssh経由でプログレスバーを表示するにはどうすればいいですか
ssh.exec!(cmd)
で (previous stackoverflow question.を参照)
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
require 'net/sftp'
require 'highline/import'
file = ARGV[ ARGV.index('-i') + 1] if ARGV.include?('-i')
puts 'No input file specified' unless file;
host = "10.0.0.10"
user = "user"
prod = "new-#{file}" # product filename (call it <file>-new)
rpath = "/home/#{user}/.rffmpeg" # remote computer operating directory
rfile = "#{rpath}/#{file}" # remote filename
rprod = "#{rpath}/#{prod}" # remote product
cmd = "ffmpeg -i #{rfile} #{rprod}"# remote command, constructed
pass = ask("Password: ") { |q| q.echo = false } # password from stdin
Net::SSH.start(host, user) do |ssh|
ssh.sftp.connect do |sftp|
# upload local 'file' to remote 'rfile'
sftp.upload!(file, rfile)
# run remote command 'cmd' to produce 'rprod'
ssh.exec!(cmd)
# download remote 'rprod' to local 'prod'
sftp.download!(rprod, prod)
end
end
は今、私の問題があります。しかし、それを作る
puts ssh.exec!(cmd)
私はコマンドの実行が終了した後に結果を得るだけです。この作業を行うためにコードをどのように変更する必要がありますか? ri Net::SSH::start
から
進行状況バーは正しく表示されませんでしたか?右? – Stefan