1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #!/bin/bash url=$1 dir=$2
echo $1 $2 download() { cd $dir &> /dev/null if [ $? - ne 0 ] then read -p "$dir No such file or directory,create now?(y/n)" answer if [ "$answer" == "y" ]; then mkdir -p $dir cd $dir wget $url &> /dev/null if [ $? - ne 0 ]; then return "52" fi else return "51" fi else wget $url &> /dev/null if [ $? - ne 0 ]; then return "52" fi fi }
download $url $dir ret=$? echo $ret # if [ $ret == 0 ]; then # echo "Download successfully." # else # echo "Download failed." # fi #
|