#!/bin/bash USER="lucas" DEST="~/Downloads" get_config() { while [[ ${1:0:1} == - ]]; do echo "Param: $1" [[ $1 == -h ]] && { if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi HOST="$2" shift 2; continue; }; [[ $1 == -f ]] && { if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi file="$2" shift 2; continue; }; [[ $1 == -o ]] && { if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi opt="$2" shift 2; continue; }; [[ $1 == -d ]] && { if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi DEST="$2" shift 2; continue; }; [[ $1 == -p ]] && { DEST="~/Videos/.stuff" shift 1; continue; }; [[ $1 == --help ]] && { usage exit }; echo "Parameter $1 discarded" usage exit done } usage() { printf "Usage: -h \tRemote Hostname -f \tPath of local file -o \tGive additional Options -d \tChoose other Destination Folder -p\t\tChange Destination --help\t\tDisplay Usage\n" exit } get_config "$@" if [ "${HOST}" == "deluge" ]; then HOST="serverhost" USER="deluge-user" DEST="/home/deluge-user/Downloads/Torrents/" fi echo "Copy ${file} to ${HOST}:${DEST}" scp -r ${opt} "${file}" ${USER}@${HOST}:${DEST}