Skip to content

Instantly share code, notes, and snippets.

@jmakeig
Last active May 9, 2020 11:42
Show Gist options
  • Save jmakeig/1913f50def91f4c5f7f1802cee7a6b81 to your computer and use it in GitHub Desktop.
Save jmakeig/1913f50def91f4c5f7f1802cee7a6b81 to your computer and use it in GitHub Desktop.
Evaluates JavaScript against MarkLogic from the command line
#!/usr/bin/env bash
# Pipes stdin as the JavaScript body of a REST Client API eval request
#
# Usage:
# cat mycode.sjs | marklogic-eval.sh
# pbpaste | marklogic-eval.sh
cat <(echo 'javascript=') <(cat -) | curl http://localhost:8000/v1/eval \
--digest -u admin:admin -X POST \
-H 'Accept: multipart/mixed' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d @-
# TODO: Specify query type as command line option
# TODO: Parse query type from file extension
# TODO: Parse multipart output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment