logo

sshpaste

Simple paste script to a server having SSH+HTTP daemons
commit: 0cb69d8fc651a87e7b250bc6e0f6c2e927b3c56c
parent: 9140ce7e79bd399e097434762d8966509621d299
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun,  6 May 2018 21:11:50 +0200

sshpaste: Read from stdin when there is no arguments

Diffstat:

MREADME2++
Msshpaste12++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -13,6 +13,8 @@ Options: -h show this help -x read input from clipboard (requires xclip) Can be used only once, not compatible with -c + + When no options or files are given, ${1} reads from stdin, it assumes plain text is given and so puts a .txt extension ``` ## Intended differences with wgetpaste diff --git a/sshpaste b/sshpaste @@ -46,6 +46,13 @@ sshpaste_command() { rm -f "${temporary_file}" } +sshpaste_stdin() { + temporary_file="$(mktemp -t sshpaste_stdin.XXXXX.txt)" + cat - > "${temporary_file}" || die "reading from stdin" + sshpaste_file "${temporary_file}" + rm -fr ${temporary_file} +} + sshpaste_usage() { cat >&2 <<EOF Usage: ${1} [options] [file(s)] @@ -55,6 +62,8 @@ Options: -h show this help -x read input from clipboard (requires xclip) Can be used only once, not compatible with -c + + When no options or files are given, ${1} reads from stdin, it assumes plain text is given and so puts a .txt extension EOF } @@ -96,6 +105,9 @@ then elif [ ! -z "${opt_command}" ] then sshpaste_command ${opt_command} +elif [ "$#" -eq 0 ] +then + sshpaste_stdin else # try to upload the rest of the arguments if they are files shift $(($OPTIND - 1))