All pastes #621055 Raw Edit

Untitled

public shellscript v1 · immutable
·published 2007-07-15 22:22 UTC
rendered paste body
#!/bin/bashbasedir=/mnt/fileserver/storage2/torrentflux/.torrents/torrentStat=($basedir*.stat)namelength=10# arrays to hold information about each torrent# arrPerc=# arrTimeLeft=# arrDownload=# arrUpload=# arrUser=# arrSeeders=# arrPeers=# arrRatio=# arrError=# arrDataUp=# arrDataDown=# arrSize=# arrName=readstat(){  local isActive=1  local i=0  #loop through all .stat files  for file in "${torrentStat[@]}"  do    ((i=0))    while read raw    do      if ((i==0))      then        if [ "$raw" == "0" ]        then          isActive=0        else          isActive=1        fi      fi      if ((isActive==1))      then        case "$i" in          0 )  arrName+=("$file") ;;          1 )  arrPerc+=("$raw") ;;          2 )  arrTimeLeft+=("$raw") ;;          3 )  arrDownload+=("$raw") ;;          4 )  arrUpload+=("$raw") ;;          5 )  arrUser+=("$raw") ;;          6 )  arrSeeders+=("$raw") ;;          7 )  arrPeers+=("$raw") ;;          8 )  arrRatio+=("$raw") ;;          9 )  arrError+=("$raw") ;;          10 ) arrDataUp+=("$raw") ;;          11 ) arrDataDown+=("$raw") ;;          12 ) arrSize+=("$raw") ;;        esac      fi      ((i++))    done < "$file"  done}listactive(){  local activeTorrents="${#arrPerc[@]}"  local i=0  local name  for ((i=0; i < activeTorrents; i++))  do    name=${arrName[i]##*/}    name=${name%.stat}    name=${name:0:namelength}    echo "${arrPerc[i]}% $name Time Left: ${arrTimeLeft[i]} dl: ${arrDownload[i]} ul: ${arrUpload[i]} Swarm: ${arrSeeders[i]}"  done}#######INIT########readstatlistactive