t4t

minimal, consent-based webpaste
git clone git://git.girlpoison.org/t4t
Log | Files | Refs | README | LICENSE

t4t (640B)


      1 #!/bin/sh
      2 PROGNAME="$(basename $0)"
      3 
      4 err() { echo "$PROGNAME: $*" >&2; }
      5 usage() { err "usage: $PROGNAME [-u user] [-h host] [files...]"; }
      6 randstring() { tr -dc 'A-Za-z0-9_\-' </dev/urandom | head -c "${1-8}"; }
      7 
      8 while getopts "u:h:" OPT; do
      9 	case ${OPT} in
     10 	u) T4T_USER="${OPTARG}";;
     11 	h) T4T_HOST="${OPTARG}";;
     12 	*) usage; exit 1;;
     13 	esac
     14 done
     15 shift $((OPTIND-1))
     16 
     17 [ "$T4T_HOST" ] || { err "set T4T_HOST or pass -h"; exit 1; }
     18 
     19 for F in "${@:--}"; do
     20 	unset NAME
     21 	if [ "$F" != "-" ]; then
     22 		[ ! -e "$F" ] && { err "no such file '$F'"; continue; }
     23 		NAME="$(basename "$F")"; 
     24 	fi
     25 
     26 	cat "$F" | ssh -T "${T4T_USER-t4t}@$T4T_HOST" "$NAME"
     27 done