Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I display progress bars from a shell command over ssh
    text
    copied!<p>I've got a script thats supposed to mimic ffmpeg on my local machine, by sending the command of to a remote machine, running it there and then returning the results. (see <a href="https://stackoverflow.com/questions/871296/how-do-i-use-ffmpeg-on-a-remote-machine-via-ssh">previous <em>stack<strong>overflow</em></strong> question.</a>)</p> <pre><code>#!/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 &lt;file&gt;-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 </code></pre> <hr> <p><strong>now my problem is at</strong></p> <pre><code>ssh.exec!(cmd) </code></pre> <p>I want to display the cmd's output to the local user in <strong>real-time</strong>. But making it</p> <pre><code>puts ssh.exec!(cmd) </code></pre> <p>I only get the resulting output after the command has finished running. How would I have to change the code to make this work?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload