Skript pro ukládání fotek z kamer: Porovnání verzí

Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
Bez shrnutí editace
mBez shrnutí editace
Řádek 9: Řádek 9:
         echo "-n NAME  name of image"
         echo "-n NAME  name of image"
         echo "-u LOGIN  user to authentication"
         echo "-u LOGIN  user to authentication"
         echo "-u PASSWD password to authentication"
         echo "-p PASSWD password to authentication"
  }
  }
   
   

Verze z 2. 12. 2011, 06:28

#!/bin/bash

function usage()
{
       echo "Usage: $0 [options] URL"
       echo "Options:"
       echo "-h        print this help"
       echo "-d DIR    download to DIR"
       echo "-n NAME   name of image"
       echo "-u LOGIN  user to authentication"
       echo "-p PASSWD password to authentication"
}

DIR=`pwd`"/"
NAME=`date +%Y%m%d%H%M`".jpg"

USER=""
PASSWORD=""

while getopts "d:n:p:u:" o;
do
        case "$o" in
                d)
                        DIR="$OPTARG"
                        ;;
                n)
                        NAME="$OPTARG"
                        ;;
                p)
                        PASSWORD="$OPTARG"
                        ;;
                u)
                        USER="$OPTARG"
                        ;;
        esac
done

shift $((OPTIND-1))

if [ -z "$1" ]
then
        usage
        exit 1
fi

wget "$1" --user "$USER" --password "$PASSWORD" -O "$DIR$NAME"