Update for OOM integration
[dmaap/datarouter.git] / datarouter-prov / src / main / resources / misc / provcmd
index 75d0bff..e3654eb 100644 (file)
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
+urlencode() {
+    local data
+    if [[ $# != 1 ]]; then
+        echo "Usage: $0 string-to-urlencode"
+        return 1
+    fi
+    data="$(curl -s -o /dev/null -w %url_effective --get --data-urlencode "$1" "")"
+    if [[ $? != 3 ]]; then
+        echo "Unexpected error" 1>&2
+        return 2
+    fi
+    echo "${data##/?}"
+    return 0
+}
+export urlencode
 
 PATH=/opt/app/datartr/bin:/bin:/usr/bin:$PATH
 PROVCMD="$0"