Created
January 25, 2013 17:35
-
-
Save indrora/4636356 to your computer and use it in GitHub Desktop.
downloader using fifo in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FIFOPATH="/tmp/perpetudl" | |
DLPATH="/home/indrora/downloads/" | |
function pd_help | |
{ | |
echo "USAGE: $0 [OPTIONS]" | |
echo "Options:" | |
echo " -a start a download" | |
echo " -s start perpetudl" | |
echo " -c clean up after an old instance" | |
echo "" | |
echo "written by morgan gangwere <[email protected]>" | |
} | |
function pd_cleanup | |
{ | |
rm -f $FIFOPATH | |
} | |
function pd_run | |
{ | |
pd_cleanup; | |
mkfifo $FIFOPATH | |
cd $DLPATH | |
while true; do | |
DLURI=$(cat $FIFOPATH) | |
wget $DLURI | |
done | |
pd_cleanup; | |
} | |
case $1 in | |
-a) | |
if [ -f FIFOPATH ]; then | |
URL=$2 | |
echo $2 > $FIFOPATH | |
else | |
echo "Not running! Start it!"; | |
fi | |
;; | |
-s) | |
pd_run; | |
;; | |
-c) | |
pd_cleanup; | |
;; | |
*) | |
pd_help; | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment