A progress bar (gauge box) -- dialog Linux
来源:互联网 发布:python sin cos 编辑:程序博客网 时间:2024/05/21 21:40
- You can create a progress bar (progress indicator) when copying/moving files or making backups using thegauge box.
- It displays a meter along the bottom of the box. The meter indicates the percentage. New percentages are read from standard input, one integer per line. The meter is updated to reflect each new percentage.
- If the standard input reads the string "START_BAR", then the first line following is taken as an integer percentage, then subsequent lines up to another "START_BAR" are used for a new prompt. The gauge exits when EOF is reached on the standard input.
- The syntax is as follows:
echo percentage | dialog --gauge "text" height width percentecho "10" | dialog --gauge "Please wait" 10 70 0echo "50" | dialog --gauge "Please wait" 10 70 0echo "100" | dialog --gauge "Please wait" 10 70 0
- However, you need to use the while or for loop to show 0 to 100% progress. In this example, the for loop is used to display progress:
for i in $(seq 0 10 100) ; do sleep 1; echo $i | dialog --gauge "Please wait" 10 70 0; done
Example
Create a shell script dvdcopy.sh:
#!/bin/bash# dvdcopy.sh - A sample shell script to display a progress bar# set counter to 0 counter=0(# set infinite while loopwhile :docat <<EOFXXX$counterDisk copy /dev/dvd to /home/data ( $counter%):XXXEOF# increase counter by 10(( counter+=10 ))[ $counter -eq 100 ] && break# delay it a specified amount of time i.e 1 secsleep 1done) |dialog --title "File Copy" --gauge "Please wait" 7 70 0
Save and close the file. Run it as follows:
chmod +x dvdcopy.sh./dvdcopy.sh
Sample outputs:
File Copy Progress Bar With Dialog
- Create a shell script called pcp.sh:
#!/bin/bash# pcp.sh: A shell script to copy /bin/* and /etc/* files# Display a progress bar while copying files. # * Based upon Greg's (GreyCat's) GPLd wiki example. *# --------------------------------------------------------# Create an array of all files in /etc and /bin directoryDIRS=(/bin/* /etc/*) # Destination directoryDEST="/tmp/test.$$" # Create $DEST if does not exits[ ! -d $DEST ] && mkdir -p $DEST ## Show a progress bar# ---------------------------------# Redirect dialog commands input using substitution#dialog --title "Copy file" --gauge "Copying file..." 10 75 < <( # Get total number of files in array n=${#DIRS[*]}; # set counter - it will increase every-time a file is copied to $DEST i=0 # # Start the for loop # # read each file from $DIRS array # $f has filename for f in "${DIRS[@]}" do # calculate progress PCT=$(( 100*(++i)/n )) # update dialog box cat <<EOFXXX$PCTCopying file "$f"...XXXEOF # copy file $f to $DEST /bin/cp $f ${DEST} &>/dev/null done) # just delete $DEST directory/bin/rm -rf $DEST
Save and close the file. Run it as follows:
chmod +x pcp.sh./pcp.sh
- A progress bar (gauge box) -- dialog Linux
- Create a Progress Bar with Win32 project
- Showing progress bar in a status bar pane
- Showing progress bar in a status bar pane
- progress bar
- Custom Control for Text Over a Progress Bar
- come on,make a date progress bar together!
- Showing Windows Progress Bar
- USE Progress Bar
- JQuery Progress Bar
- SlickUpload(Upload Progress Bar)
- APIDEMO PROGRESS BAR
- Android 自定义Progress Bar
- progress bar color
- Android 自定义Progress Bar
- 【AndEngine】Progress Bar HUD
- Android 自定义Progress Bar
- bootstrap中的 progress bar
- ScriptCase开发平台介绍(十二)——控制(Control)应用程序
- hibenate.hbm2ddl.auto属性详解
- 骑摩托被线勒住脖子 男子险遭风筝线割喉
- STL priority_queue 优先队列
- 昨天jlink不能用了
- A progress bar (gauge box) -- dialog Linux
- Hibernate 一对多外键双向关联
- Collection
- Hibernate 一对多连接表双向关联
- XML Utility
- MHDD使用方法以及图文教程(简洁教程)
- Hibernate 多对多双向关联
- 1.写student类中的select,delete,update,insert方法并在objectDataSource中应用(分别写两个,一个返回datatable,一个使用list)
- <5>c语言实现ATM存取款系统(文件、排序)