Last active
May 18, 2019 23:50
-
-
Save tobiasKaminsky/38f7e8afbb9c7d0b94f7c8529c7a2de0 to your computer and use it in GitHub Desktop.
pasteNC Script - pass file/text to nextdrop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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