tupload files to a remote shell via scp - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit af411cf91858bfb452dc2b517791fdc818386876
 (DIR) parent 2434d446b4622c0efd9da1d450dc71f6d6b8ed6a
 (HTM) Author: Willy Goiffon <w.goiffon@gmail.com>
       Date:   Tue, 18 Jun 2013 10:48:46 +0200
       
       upload files to a remote shell via scp
       
       Diffstat:
         A upload                              |      43 ++++++++++++++++++++++++++++++
       
       1 file changed, 43 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/upload b/upload
       t@@ -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