summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-01-09 10:50:39 -0800
committerMatthew Sotoudeh <matthew@masot.net>2023-01-09 10:50:39 -0800
commit3231f8011dc149ee20fb0fd268658a072e11b014 (patch)
treed48395b4c566ae6078a055daa5c046f63c18a603
xprint script
-rwxr-xr-xxprint39
1 files changed, 39 insertions, 0 deletions
diff --git a/xprint b/xprint
new file mode 100755
index 0000000..2bc8efb
--- /dev/null
+++ b/xprint
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+print_single() {
+ truncate -s 0 cookiejar
+ page=$(curl -c cookiejar --insecure "https://xerox4.stanford.edu/print/print.php")
+ # https://fabianlee.org/2020/01/29/bash-using-bash_rematch-to-pull-capture-groups-from-a-regex/
+ [[ $page =~ CSRFToken\"\ value=\"([^\"]+)\" ]]
+ csrf=${BASH_REMATCH[1]}
+ curl --silent --show-error \
+ 'https://xerox4.stanford.edu/upload/xerox.set' \
+ --insecure \
+ --cookie cookiejar \
+ -H 'Referer: https://xerox4.stanford.edu/print/print.php' \
+ -X POST \
+ -F 'job_type=print' \
+ -F 'plex=duplex' \
+ -F 'color_mode=automatic' \
+ -F 'finishing=staple' \
+ -F "CSRFToken=$csrf" \
+ -F _adm_SJ=@$1 \
+ > /dev/null
+
+ rm cookiejar
+
+ # Other options: job_password, job_print_after, save_disposition,
+ # save_location, save_name, copy_count, output, content_orientation,
+ # feed_edge, fold, booklet, fold_image_Option, punch, output_face_up,
+ # output_bins, default_medium_colour, default_medium, input_tray_select,
+ # default_medium_type, accounting_information_avp
+}
+
+for x in $@
+do
+ echo "Printing $x"
+ print_single $x
+ echo "Sent to printer!"
+ echo "Waiting 0.5s ..."
+ sleep "0.5s"
+done
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback