a Little Notes

Ikon

TUlisan dan Contekan

Wget Download

Scripts untuk wget

#!/bin/bash

cd $HOME/downloads/
PATH=/bin:/usr/bin

line=1
max_proc=3
list_file=”$HOME/downloads/todo.txt”
prog=”/usr/local/bin/wget”

while true
do
while true
do
proc=`ps -f -u $USER | grep -c $prog`
# grep is in the list too
let proc–

lines=`grep -c “” $list_file`
echo “Proc: $proc / $max_proc Line: $line / $lines”

[[ $proc -ge $max_proc || $line -gt $lines ]] && break

params=`grep -n “” $list_file | grep “^$line:” |
sed -e “s/^$line://”`
echo $params | tee -a done.txt archive.txt

# ignore empty lines
if [ “$params” ]; then
$prog -b $params
sleep 3
fi
let line++
done

echo “Waiting…”
sleep 10
done

Iklan

Filed under: scripts

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: