31 lines
704 B
Bash
Executable File
31 lines
704 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
# Put files on a webspace via sftp
|
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
zmodload zsh/zutil
|
|
local -a o_dir=(-d "")
|
|
local -a o_help=()
|
|
zparseopts -D -K -- d:=o_dir h=o_help
|
|
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
|
local ret=$(( ${#o_help} ^ 1 ))
|
|
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] [-d REMOTE SUBDIR] <FILE> …"
|
|
return ${ret}
|
|
fi
|
|
local dir=""
|
|
[[ -n ${o_dir[2]} ]] && dir=${o_dir[2]}/
|
|
|
|
local -a putcmds
|
|
for file in "${@}"; do
|
|
putcmds+="put ${file}"
|
|
done
|
|
|
|
sftp tastytea.de <<EOF
|
|
cd /var/www/tastytea.de/files/${dir}
|
|
$(print -l ${putcmds})
|
|
EOF
|
|
|
|
for file in "${@}"; do
|
|
print '\e[1;95m→\e[0m' https://tastytea.de/files/${dir}"${file##*/}"
|
|
done
|