paste_senden.sh aktualisiert
This commit is contained in:
@ -1,12 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
FILE="$1" # Pfad als erstes Argument beim Aufruf: ./script.sh datei.txt
|
FILE="$1"
|
||||||
|
HOST="${2:-http://localhost:8000}"
|
||||||
|
|
||||||
curl -X POST \
|
if [ -z "$FILE" ]; then
|
||||||
-d 'api_dev_key=RdWPnCdyvMdV1YNr_Un-aw0zfbWnspff' \
|
echo "Verwendung: $0 <datei> [host]"
|
||||||
-d 'api_paste_name=tmp.txt' \
|
exit 1
|
||||||
--data-urlencode "api_paste_code@$FILE" \
|
fi
|
||||||
-d 'api_option=paste' \
|
|
||||||
"https://pastebin.com/api/api_post.php"
|
|
||||||
|
|
||||||
echo
|
if [ ! -f "$FILE" ]; then
|
||||||
|
echo "Datei nicht gefunden: $FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONTENT=$(cat "$FILE")
|
||||||
|
FILENAME=$(basename "$FILE")
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -X POST "$HOST/api/v1/paste" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"expiry\": \"1day\",
|
||||||
|
\"files\": [{
|
||||||
|
\"name\": \"$FILENAME\",
|
||||||
|
\"lexer\": \"text\",
|
||||||
|
\"content\": $(echo "$CONTENT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')
|
||||||
|
}]
|
||||||
|
}")
|
||||||
|
|
||||||
|
LINK=$(echo "$RESPONSE" | python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["link"])' 2>/dev/null)
|
||||||
|
|
||||||
|
if [ -z "$LINK" ]; then
|
||||||
|
echo "Fehler: $RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Paste URL: $LINK"
|
||||||
|
echo "Paste-ID: $(basename $LINK)"
|
||||||
Reference in New Issue
Block a user