scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit af411cf91858bfb452dc2b517791fdc818386876
parent 2434d446b4622c0efd9da1d450dc71f6d6b8ed6a
Author: Willy Goiffon <w.goiffon@gmail.com>
Date:   Tue Jun 18 10:48:46 +0200

upload files to a remote shell via scp

Diffstat:
upload | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/upload b/upload @@ -0,0 +1,43 @@ +#!/usr/bin/bash + +host=ssh.blinkenshell.org +user=z3bra +port=443 +path=public_html +base=z3bra.blinkenshell.org + +file='' +tmpfile=/tmp/paste + +clear > $tmpfile + +if [[ $# -eq 0 ]]; then + while read line; do + echo ${line} >> $tmpfile + done + + file=$tmpfile +else + file=$@ +fi + +for f in $file; do + case $(file $f| grep -o -E 'text|image') in + text) + ext=txt + ;; + image) + ext=img + ;; + *) + ext=rand + ;; + esac + + name=$(echo $f| sed 's@^.*/\([a-zA-Z0-9.]*\)$@\1@') + + url="http://${base}/${ext}/${name}" + scp -P ${port} $f ${user}@${host}:${path}/$ext/$name && echo $url +done + +[[ -f $tmpfile ]] && rm $tmpfile