1.\" Copyright (c) 2013-2016 Devin Teske 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd January 26, 2016 28.Dt DPV 1 29.Os 30.Sh NAME 31.Nm dpv 32.Nd stream data from stdin or multiple paths with dialog progress view 33.Sh SYNOPSIS 34.Nm 35.Op options 36.Ar [bytes:]label 37.Nm 38.Op options 39.Fl m 40.Ar [bytes1:]label1 41.Ar path1 42.Op Ar [bytes2:]label2 path2 ... 43.Sh DESCRIPTION 44.Nm 45provides a dialog progress view, allowing a user to see current throughput rate 46and total data transferred for one or more streams. 47.Pp 48The 49.Nm 50utility has two main modes for processing input. 51.Pp 52The default input mode, without 53.Ql Fl m , 54.Nm 55reads bytes from standard input. 56A label for the data must be provided. 57.Pp 58The secondary input mode, with 59.Ql Fl m , 60.Nm 61reads multiple paths 62.Pq up to 2047 or Dq ARG_MAX/2-1 , 63sequentially. 64.Pp 65Data read in either mode is either thrown away 66.Pq default , 67sent to a spawned instance of the program specified via 68.Ql Fl x Ar cmd , 69or sent to a unique file specified by 70.Ql Fl o Ar file . 71.Pp 72With or without 73.Ql Fl m , 74progress is displayed using one of 75.Xr dialog 3 76.Pq default , 77.Xr dialog 1 78.Pq see Ql Fl D , 79or instead 80.Xr Xdialog 1 81.Pq see Ql Fl X . 82.Pp 83The following options are available: 84.Bl -tag -width ".Fl b Ar backtitle" 85.It Fl a Ar text 86Display 87.Ar text 88below the file progress indicator(s). 89.It Fl b Ar backtitle 90Display 91.Ar backtitle 92on the backdrop, at top-left, behind the dialog widget. 93When using 94.Xr Xdialog 1 , 95this is displayed inside the window 96.Pq at the top 97followed by a separator line. 98.It Fl d 99Debug mode. 100Print dialog prompt data to standard out and provide additional debugging on 101standard error. 102.It Fl D 103Do not use the default interface of 104.Xr dialog 3 , 105but instead spawn an instance of 106.Xr dialog 1 . 107The path to 108.Xr dialog 1 109is taken from the 110.Ev DIALOG 111environment variable or simply 112.Dq Li dialog 113if unset or NULL. 114.It Fl h 115Produce a short syntax usage with brief option descriptions and exit. 116Output is produced on standard error. 117.It Fl i Ar format 118Customize the single-file format string used to update the status line. 119Ignored when using either 120.Ql Fl D 121or 122.Ql Fl X 123which lack the ability to display the status line 124.Pq containing bytes/rate/thread information . 125Default value 126is 127.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. . 128This format is used when handling one file. 129.It Fl I Ar format 130Customize the multi-file format string used to update the status line. 131Ignored when using either 132.Ql Fl D 133or 134.Ql Fl X 135which lack the ability to display the status line 136.Pq containing bytes/rate/thread information . 137Default value 138is 139.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. [%i/%i busy/wait] . 140This format is used when handling more than one file. 141.It Fl k 142Keep tite. 143Prevent visually distracting initialization/exit routines for scripts running 144.Xr dialog 1 145several times. 146.It Fl l 147Line mode. Read lines from input instead of bytes. 148.It Fl L Ar size 149Label size. 150If negative, shrink to longest label width. 151.It Fl m 152Multi-input mode. 153Instead of reading bytes from standard input, read from a set of paths 154.Pq one for each label . 155By default, each path is processed sequentially in the order given. 156.It Fl n Ar num 157Display at-most 158.Ar num 159progress indicators per screen. 160If zero, display as many as possible. 161If negative, only display the main progress indicator. 162Default is 0. 163Maximum value is 10. 164.It Fl N 165No overrun. 166If enabled, stop reading known-length inputs when input reaches stated length. 167.It Fl o Ar file 168Output data to 169.Ar file . 170The first occurrence of 171.Ql %s 172.Pq if any 173in 174.Ql Ar file 175will be replaced with the 176.Ar label 177text. 178.It Fl p Ar text 179Display 180.Ar text 181above the file progress indicator(s). 182.It Fl P Ar size 183Mini-progressbar size. 184If negative, don't display mini-progressbars 185.Pq only the large overall progress indicator is shown . 186If zero, auto-adjust based on number of files to read. 187When zero and only one file to read, defaults to -1. 188When zero and more than one file to read, defaults to 17. 189.It Fl t Ar title 190Display 191.Ar title 192atop the dialog box. 193Note that if you use this option at the same time as 194.Ql Fl X 195and 196.Ql Fl b Ar backtitle , 197the 198.Ar backtitle 199and 200.Ar title 201are effectively switched 202.Pq see BUGS section below . 203.It Fl T 204Test mode. 205Simulate reading a number of bytes, divided evenly across the number of files, 206while stepping through each percent value of each file to process. 207Appends 208.Dq Li [TEST MODE] 209to the status line 210.Pq to override, use Ql Fl u Ar format . 211No data is actually read. 212.It Fl U Ar num 213Update status line 214.Ar num 215times per-second. 216Default value is 217.Ql Li 2 . 218A value of 219.Ql Li 0 220disables status line updates. 221If negative, update the status line as fast as possible. 222Ignored when using either 223.Ql Fl D 224or 225.Ql Fl X 226which lack the ability to display the status line 227.Pq containing bytes/rate/thread information . 228.It Fl w 229Wide mode. 230Allows long 231.Ar text 232arguments used with 233.Ql Fl p 234and 235.Ql Fl a 236to bump the dialog width. 237Prompts wider than the maximum width will wrap 238.Pq unless using Xr Xdialog 1 ; see BUGS section below . 239.It Fl x Ar cmd 240Execute 241.Ar cmd 242.Pq via Xr sh 1 243and send it data that has been read. 244Data is available to 245.Ar cmd 246on standard input. 247With 248.Ql Fl m , 249.Ar cmd 250is executed once for each 251.Ar path 252argument. 253The first occurrence of 254.Ql %s 255.Pq if any 256in 257.Ql Ar cmd 258will be replaced with the 259.Ar label 260text. 261.It Fl X 262Enable X11 mode by using 263.Xr Xdialog 1 264instead of 265.Xr dialog 1 266or 267.Xr dialog 3 . 268.El 269.Sh ENVIRONMENT 270The following environment variables are referenced by 271.Nm : 272.Bl -tag -width ".Ev USE_COLOR" 273.It Ev DIALOG 274Override command string used to launch 275.Xr dialog 1 276.Pq requires Ql Fl D 277or 278.Xr Xdialog 1 279.Pq requires Ql Fl X ; 280default is either 281.Ql dialog 282.Pq for Ql Fl D 283or 284.Ql Xdialog 285.Pq for Ql Fl X . 286.It Ev DIALOGRC 287If set and non-NULL, path to 288.Ql .dialogrc 289file. 290.It Ev HOME 291If 292.Ql Ev $DIALOGRC 293is either not set or NULL, used as a prefix to 294.Ql .dialogrc 295.Pq i.e., Ql $HOME/.dialogrc . 296.It Ev USE_COLOR 297If set and NULL, disables the use of color when using 298.Xr dialog 1 299.Pq does not apply to Xr Xdialog 1 . 300.El 301.Sh DEPENDENCIES 302If using 303.Ql Fl D , 304.Xr dialog 1 305is required. 306.Pp 307If using 308.Ql Fl X , 309.Xr Xdialog 1 310is required. 311.Sh FILES 312.Bl -tag -width ".Pa $HOME/.dialogrc" -compact 313.It Pa $HOME/.dialogrc 314.El 315.Sh EXAMPLES 316Simple example to show how fast 317.Xr yes 1 318produces lines 319.Pq usually about ten-million per-second; your results may vary : 320.Bd -literal -offset indent 321yes | dpv -l yes 322.Ed 323.Pp 324Display progress while timing how long it takes 325.Xr yes 1 326to produce a half-billion lines 327.Pq usually under one minute; your results may vary : 328.Bd -literal -offset indent 329time yes | dpv -Nl 500000000:yes 330.Ed 331.Pp 332An example to watch how quickly a file is transferred using 333.Xr nc 1 : 334.Bd -literal -offset indent 335dpv -x "nc -w 1 somewhere.com 3000" -m label file 336.Ed 337.Pp 338A similar example, transferring a file from another process and passing the 339expected size to 340.Nm : 341.Bd -literal -offset indent 342cat file | dpv -x "nc -w 1 somewhere.com 3000" 12345:label 343.Ed 344.Pp 345A more complicated example: 346.Bd -literal -offset indent 347tar cf - . | dpv -x "gzip -9 > out.tgz" \\ 348 $( du -s . | awk '{print $1 * 1024}' ):label 349.Ed 350.Pp 351Taking an image of a disk: 352.Bd -literal -offset indent 353dpv -o disk-image.img -m label /dev/ada0 354.Ed 355.Pp 356Writing an image back to a disk: 357.Bd -literal -offset indent 358dpv -o /dev/ada0 -m label disk-image.img 359.Ed 360.Pp 361Zeroing a disk: 362.Bd -literal -offset indent 363dpv -o /dev/md42 < /dev/zero 364.Ed 365.Sh SEE ALSO 366.Xr dialog 1 , 367.Xr sh 1 , 368.Xr Xdialog 1 , 369.Xr dialog 3 370.Sh HISTORY 371A 372.Nm 373utility first appeared in 374.Fx 10.2 . 375.Sh AUTHORS 376.An Devin Teske Aq dteske@FreeBSD.org 377.Sh BUGS 378.Xr Xdialog 1 , 379when given both 380.Ql Fl -title Ar title 381.Pq see above Ql Fl t Ar title 382and 383.Ql Fl -backtitle Ar backtitle 384.Pq see above Ql Fl b Ar backtitle , 385displays the backtitle in place of the title and vice-versa. 386.Pp 387.Xr Xdialog 1 388does not wrap long prompt texts received after initial launch. 389This is a known issue with the 390.Ql --gauge 391widget in 392.Xr Xdialog 1 . 393.Pp 394.Xr dialog 1 395does not display the first character after a series of escaped escape-sequences 396(e.g., ``\\\\n'' produces ``\\'' instead of ``\\n''). 397This is a known issue with 398.Xr dialog 1 399and does not affect 400.Xr dialog 3 401or 402.Xr Xdialog 1 . 403.Pp 404If your application ignores 405.Ev USE_COLOR 406when set and NULL before calling 407.Xr dpv 1 408with color escape sequences anyway, 409.Xr dialog 3 410and 411.Xr dialog 1 412may not render properly. 413Workaround is to detect when 414.Ev USE_COLOR 415is set and NULL and either not use color escape sequences at that time or use 416.Xr unset 1 417.Xr [ sh 1 ] 418or 419.Xr unsetenv 1 420.Xr [ csh 1 ] 421to unset 422.Ev USE_COLOR , 423forcing interpretation of color sequences. 424This does not effect 425.Xr Xdialog 1 , 426which renders the color escape sequences as plain text. 427See 428.Do 429embedded "\\Z" sequences 430.Dc 431in 432.Xr dialog 1 433for additional information. 434