Skip to content

Instantly share code, notes, and snippets.

@indrora
Created January 25, 2013 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indrora/4636356 to your computer and use it in GitHub Desktop.
Save indrora/4636356 to your computer and use it in GitHub Desktop.
downloader using fifo in bash
#!/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 <indrora@earfolds.com>"
}
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