Skip to content

Commit

Permalink
send2pastebin: support stdin and commands with arguments, and more!
Browse files Browse the repository at this point in the history
  • Loading branch information
gtxaspec committed May 22, 2024
1 parent 13678b3 commit e806a46
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions overlay/lower/usr/sbin/send2pastebin
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
#!/bin/sh

if [ -z "$1" ]; then
echo "Usage: $0 <filename|command>"
exit 1
fi
if [ -t 0 ]; then
if [ -z "$1" ]; then
echo "Usage: $0 <command>"
exit 1
fi

if [ -f "$1" ]; then
file="$1"
elif which "$1" > /dev/null; then
file=$(mktemp)
command "$1" > "$file"
sh -c "$*" > "$file" 2>&1
else
echo "Cannot find file of command $1"
exit 2
file=$(mktemp)
cat - > "$file"
fi

if [ -z "$(cat "$file")" ]; then
echo "File $file is empty"
exit 3
fi
[ -s "$file" ] || { echo "File $file is empty"; exit 3; }

url=$(cat "$file" | nc termbin.com 9999)
url=$(nc termbin.com 9999 < "$file")
echo "$url"

rm -f "$file"
exit 0

0 comments on commit e806a46

Please sign in to comment.