paste_senden.sh aktualisiert

This commit is contained in:
alf
2026-04-23 20:26:19 +00:00
parent 64a00e9b9c
commit ea5ff744a1

View File

@ -1,12 +1,38 @@
#!/bin/bash
FILE="$1" # Pfad als erstes Argument beim Aufruf: ./script.sh datei.txt
FILE="$1"
HOST="${2:-http://localhost:8000}"
curl -X POST \
-d 'api_dev_key=RdWPnCdyvMdV1YNr_Un-aw0zfbWnspff' \
-d 'api_paste_name=tmp.txt' \
--data-urlencode "api_paste_code@$FILE" \
-d 'api_option=paste' \
"https://pastebin.com/api/api_post.php"
if [ -z "$FILE" ]; then
echo "Verwendung: $0 <datei> [host]"
exit 1
fi
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)"