Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] Code Query-Bittorrent Scripts
- Date: Sat, 21 Jan 2006 01:14:05 +0900
- From: Mark Sargent <powderkeg@example.com>
- Subject: [tlug] Code Query-Bittorrent Scripts
- User-agent: Mozilla Thunderbird 1.0.6-1.4.1.centos4 (X11/20050721)
Hi All, I'm not a programmer and wish to query some of the below code, which is the only part I don't understand. Cheers Mark Sargent. Code Being Queried: BEGIN { srand() } { names[NR]=$0 } END { j=int(NR*rand()); found here, http://lue.dyn.dhs.org/2005/20050708135201.html Full Code: #!/bin/sh #bt.offer: circulate offered torrents howmany=0 offerall=0 loopctrl=0 case $1 in all) offerall=1 ;; [0-9]*) howmany=$1 ;; "") howmany=7 ;; esac # first, remove what's already being offered cd /usr/local/bt || exit 1 if [ -f $HOME/.bt/offer/offered ]; then rm $(cat $HOME/.bt/offer/offered) rm $HOME/.bt/offer/offered fi # two special cases #1): remove all offered torrents if [ $howmany -eq 0 ]; then exit 3 fi #2): offer all the torrents that I have if [ $offerall -eq 1 ]; then cd $HOME/.bt/offer || exit 2 ls *.torrent > offered cp *.torrent /usr/local/bt/ exit 0 fi # offer another batch cd $HOME/.bt/offer || exit 2 i=0 while [ $loopctrl -eq 0 ] do torrent=$(ls *.torrent | awk ' BEGIN { srand() } { names[NR]=$0 } END { j=int(NR*rand()); if (j<1) j=j+10; if (j>NR) j=NR; print names[j] } ' ) echo "$torrent" >> offered i=$(expr "$i" + 1) if [ $i -ge $howmany ]; then loopctrl=1 fi sleep 1s done sort offered | uniq > /tmp/$$ mv /tmp/$$ offered for torrent in `cat offered` do cp "$torrent" /usr/local/bt/"$torrent" done
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Docbook XML for documenting database tables
- Next by Date: Re: [tlug] Aki Day Part 2
- Previous by thread: Re: [tlug] Aki Day Part 2
- Next by thread: [tlug] Skype performance
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links