4
我正在嘗試創建一個使用--progress參數調用rsync腳本的macruby應用程序,但rsync顯示其進度的方式是通過更改同一行,而不是將新行添加到其輸出,因此如何獲取這個數據?如何從ruby獲得交互式程序的進度?
我正在嘗試創建一個使用--progress參數調用rsync腳本的macruby應用程序,但rsync顯示其進度的方式是通過更改同一行,而不是將新行添加到其輸出,因此如何獲取這個數據?如何從ruby獲得交互式程序的進度?
的Rsync可以讓你改變的信息的格式使用--log-format
選項顯示:
--log-format=FORMAT
This allows you to specify exactly what the rsync client outputs to the user on a per-file basis. The format is a text string containing embedded
single-character escape sequences prefixed with a percent (%) character. For a list of the possible escape characters, see the "log format" set-
ting in the rsyncd.conf manpage. (Note that this option does not affect what a daemon logs to its logfile.)
Specifying this option will mention each file, dir, etc. that gets updated in a significant way (a transferred file, a recreated symlink/device,
or a touched directory) unless the itemize-changes escape (%i) is included in the string, in which case the logging of names increases to mention
any item that is changed in any way (as long as the receiving side is at least 2.6.4). See the --itemize-changes option for a description of the
output of "%i".
The --verbose option implies a format of "%n%L", but you can use --log-format without --verbose if you like, or you can override the format of its
per-file output using this option.
Rsync will output the log-format string prior to a file's transfer unless one of the transfer-statistic escapes is requested, in which case the
logging is done at the end of the file's transfer. When this late logging is in effect and --progress is also specified, rsync will also output
the name of the file being transferred prior to its progress information (followed, of course, by the log-format output).
你應該能夠在飛行到的東西進行配置更可用。
另外,如果您使用popen3
,則應該能夠捕獲轉移百分比數字,並使用它創建自己的進度欄。
你應該使用IO.popen用塊符號
問題是rsync寫入同一行,我想了一個辦法,基於這個http://coderrr.wordpress.com/2008/10/21/when-to-use-readpartial-instead-of- read-in-ruby /使用IO.popen readpartial獲取部分數據。 – 2010-12-15 16:33:12