#!/bin/sh -e for arg in "$@" do case "$arg" in sh) _ext=".sh" ;; ksh) _ext=".ksh" ;; txt) _ext=".txt" ;; log) _ext=".log" ;; rm) _rm=1 ;; ls) _ls=1 ;; mv) _mv=1 ;; *) break; ;; esac shift; done if [ ! -z "$_rm" ] then for file in "$@" do ssh sdk@codevoid.de \ "cd /home/www/htdocs/ptrace/paste/ \ && rm -v $(basename "$file")" \ || true done exit 0 fi if [ ! -z "$_ls" ] then ssh sdk@codevoid.de \ "cd /home/www/htdocs/ptrace/paste/ \ && ls -1tr \ | xargs -n1 -I{} echo \"https://ptrace.org/{} ({})\"" exit 0 fi if [ ! -z "$_mv" ] then ssh sdk@codevoid.de \ "cd /home/www/htdocs/ptrace/paste/ \ && mv -v \"$1\" \"$2\"" exit 0 fi if [ ! -z "$@" ] then for file in "$@" do # make sure the file is least owner rw and group r # the sticky bit in the destiation folder will assign user+group chmod u+rw,g+r "$file" scp "$file" "sdk@codevoid.de:/home/www/htdocs/ptrace/paste/${file}${_ext}" echo "https://ptrace.org/$(basename "$file")" \ | sed 's/ /%20/g' \ | xclip -f -r echo done fi