Last active
August 29, 2015 13:57
-
-
Save petrjoachim/9363093 to your computer and use it in GitHub Desktop.
Skript s bezpečně předaným heslem do wgetu pro dávkové použití.
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 -e | |
USER=$1 | |
shift | |
read -s -p "Password for username $USER: " PASSWORD; echo | |
for FILE in "$@" | |
do | |
OUTPUT=`echo $FILE | sed "s/https*:\/\/\([^.]*\.[^.]*\).*\/\(.*\)/\1-\2/g"` | |
# v aktualnim adresari vytvorime namedpipe | |
mkfifo trubka.$$ | |
# wgetneme soubor a pockame si na predani hesla pres trubku | |
wget -O "$OUTPUT" --no-check-certificate --user "$USER" --config trubka.$$ $FILE & | |
PID=$! | |
# zapiseme do trubky heslo a trubku pak hned smazeme | |
echo -e "password=$PASSWORD\n" > trubka.$$ | |
rm -f trubka.$$ | |
# pockame az proces skonci a jede se dal | |
wait $PID | |
done |
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 -e | |
USER=$1 | |
shift | |
read -s -p "Password for username $USER: " PASSWORD; echo | |
while true; | |
do | |
for FILE in "$@" | |
do | |
OUTPUT=`echo $FILE | sed "s/https*:\/\/\([^.]*\.[^.]*\).*\/\(.*\)/\1-\2/g"` | |
# v aktualnim adresari vytvorime namedpipe | |
mkfifo trubka.$$ | |
# wgetneme soubor a pockame si na predani hesla pres trubku | |
# wget -c pokracuje ve stahovani (hodi se na tail vzdaleneho souboru) | |
wget -c -O "$OUTPUT" --no-check-certificate --user "$USER" --config trubka.$$ $FILE & | |
PID=$! | |
# zapiseme do trubky heslo a trubku pak hned smazeme | |
echo -e "password=$PASSWORD\n" > trubka.$$ | |
rm -f trubka.$$ | |
# pockame az proces skonci a jede se dal | |
wait $PID | |
sleep 1 | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ještě verze od Luboše Starého.