Skip to content

Instantly share code, notes, and snippets.

@tobiasKaminsky
Last active May 18, 2019 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tobiasKaminsky/38f7e8afbb9c7d0b94f7c8529c7a2de0 to your computer and use it in GitHub Desktop.
Save tobiasKaminsky/38f7e8afbb9c7d0b94f7c8529c7a2de0 to your computer and use it in GitHub Desktop.
pasteNC Script - pass file/text to nextdrop
#!/bin/sh
SERVER_URL=
USER=
PASS=
if [ -p /dev/stdin ] ; then
input=$(cat /dev/stdin)
fi
if [ $# -ne 1 -a -z "$input" ] ; then
echo "Please specifiy a file or pass text to it:"
echo 'pasteNC.sh $pathToFile'
echo 'pasteNC.sh "some text"'
echo 'cat $file | pasteNC.sh'
exit 1
fi
if [ -f "$1" ] ; then
curl -X POST -F "data=@$1" https://$USER:$PASS@$SERVER_URL/index.php/apps/nextdrop/drop 2>/dev/null | jq ".link" | sed s/'"'//g
exit
fi
if [ -n "$1" -o -n "$input" ] ; then
if [ -n "$1" ]; then
text="$1"
else
text="$input"
fi
curl -X POST -F "text=$text" https://$USER:$PASS@$SERVER_URL/index.php/apps/nextdrop/text 2>/dev/null | jq ".link" | sed s/'"'//g
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment