#!/usr/bin/env bash # nscp - Use scp to Upload Files to Remote Servers # License: GPL 2; share and enjoy! # Author: Sean B. Palmer, inamidst.com doc='Usage: ./nscp ' # Get configuration filename from NSCP_CONF if [[ ("$1" = '--help') || ($# != 2) ]]; then echo $doc exit elif [ ! -f "$NSCP_CONF" ]; then echo 'Error: unable to find $NSCP_CONF' >&2 exit 1 fi case $2 in /) FN='index.html';; /*/) FN=${2#/}; FN="${FN}index.html";; /*) FN=${2#/};; */) FN="${2}index.html";; *) FN=$2;; esac cat $NSCP_CONF | \ while true; do read ACCOUNT USERHOST LOCAL REMOTE if [ $? != 0 ]; then break fi if [ "$1" = "$ACCOUNT" ]; then echo "Doing: scp .../$FN $USERHOST:.../$FN" >&2 scp $LOCAL/$FN $USERHOST:$REMOTE/$FN break fi done