summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <bo.andresen@zlin.dk>2007-02-28 11:07:26 +0000
committerBo Ørsted Andresen <bo.andresen@zlin.dk>2007-02-28 11:07:26 +0000
commit5b2b2b028f79f05452b8b9aeeb8ed1efb18f3052 (patch)
treee73df41fa7d75be84e29aa070175f52bca37046d
parent9d618432b46e7343f51a3147674bd1b76a064a0d (diff)
downloadwgetpaste-5b2b2b028f79f05452b8b9aeeb8ed1efb18f3052.tar.gz
Use --post-file instead of --post-data. This requires a temporary file but increases reliability for large pastes.
-rwxr-xr-xwgetpaste15
1 files changed, 14 insertions, 1 deletions
diff --git a/wgetpaste b/wgetpaste
index 00c03c6..ea45b51 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -125,7 +125,20 @@ NICK=$(escape "${NICK}")
LANGUAGE=$(escape "${LANGUAGE}")
DESCRIPTION=$(escape "${DESCRIPTION}")
-URL=$(wget -O - --timeout=10 --post-data="lang=${LANGUAGE}&nick=${NICK}&desc=${DESCRIPTION}&cvt_tabs=${CVT_TABS}&text=${INPUT}" http://rafb.net/paste/paste.php 2>&1 | sed -n 's|^.*Location:\ \(http://rafb.net/p[^\ ]\+\).*$|\1|p')
+# create temp file (wget is much more reliable reading large input from a file than from the cli directly
+TEMPFILE="$(mktemp /tmp/wgetpaste.XXXXXX)"
+[[ -f "${TEMPFILE}" ]] || die "Failed to create a temporary file." 1>&2
+
+echo "lang=${LANGUAGE}&nick=${NICK}&desc=${DESCRIPTION}&cvt_tabs=${CVT_TABS}&text=${INPUT}" > "${TEMPFILE}" || die "Failed to write to temporary file: \"${TEMPFILE}\"."
+
+URL=$(wget -O - --timeout=10 --post-file=${TEMPFILE} http://rafb.net/paste/paste.php 2>&1 | sed -n 's|^.*Location:\ \(http://rafb.net/p[^\ ]\+\).*$|\1|p')
+
+# clean temporary file
+if [[ ! ${DEBUG} ]]; then
+ rm "${TEMPFILE}" || echo "Failed to remove temporary file: \"${TEMPFILE}\"." 1>&2
+else
+ echo "Left temporary file: \"${TEMPFILE}\" alone for debugging purposes."
+fi
if [[ "${URL}" == "http://rafb.net/p/toofast.html" ]]; then
echo "You must wait at least 10 seconds between each paste! Try again in 10 seconds."