#!/bin/bash # This script posts BeanShell script to remote endpoint and parses the response _usage_ () { echo "Usage: ./hybris_bsh []" } case $# in 0) _usage_; exit 1 ;; 1) BEANSHELL_SCRIPT=$1; BEANSHELL_URL=http://localhost:9001/console/beanshell/execute ;; 2) BEANSHELL_SCRIPT=$1; BEANSHELL_URL=$2 ;; *) echo "Too many arguments."; _usage_; exit 1 ;; esac # post script to remote endpoint and parse response echo "Posting $BEANSHELL_SCRIPT to the $BEANSHELL_URL..." OUTPUT_TEXT=$(curl -X POST --data-urlencode script@$BEANSHELL_SCRIPT $BEANSHELL_URL) # | grep -P '"outputText":.*?[^\\]",') echo "Obtained response:" # enable interpretation of backslash escapes(\n) echo -e $OUTPUT_TEXT