while getopts ":r:ilL" opt; do doRemote=false installLogin=false updateLogin=false case $opt in r) echo "remote: $OPTARG" >&2 remote="$OPTARG" doRemote=true ;; L) echo "Install login" ;; l) echo "Update Login" ;; esac if [ "$doRemote" = true ]; then scp "$0" "$remote:~/" ssh $remote "chmod +x ~/${0:2}" ssh $remote "~/${0:2}" -L fi done