Hello Mouhssine,
The multiline have some challenges in CLI. You can achieve this by writing a bash shell function to extract the file contents for elevation profile script (e.g. dlpx_pfexec, dlpx_mkdir...)
Code snippet:
extract_contents() { PROFILE_NAME="${1}" SCRIPT_FILE="${2}" CONTENTS="" row="" PFEXEC_FILE="${BASEDIR}/${PROFILE_NAME}/${SCRIPT_FILE}" if [ ! -f ${PFEXEC_FILE} ]; then echo "Error: Can't read file ${PFEXEC_FILE}" exit 1 fi IFS='' while read line || [ -n "${line}" ] do row='echo "${row}\n${line}"' done < ${PFEXEC_FILE} CONTENTS=$(echo "${row}" | sed -e 's/\"/\\\"/g' | sed -e 's/\$/'\$'/g' | sed -e 's/\t/ /g' ) }
Then pass the CONTENTS to a WebAPI call
create_profile_script()
{
URL="${1}"
PROFILE_REF="${2}"
NAME="${3}"
CONTENTS="${4}"
echo "Creating profile script ${NAME}"
RESULT='curl -s -X POST -k --data @- ${URL}/resources/json/delphix/host/privilegeElevation/profileScript \
-b ${COOKIE_FILE} -H "Content-Type: application/json" <<EOF
{
"type": "HostPrivilegeElevationProfileScript",
"profile": "${PROFILE_REF}",
"name": "${NAME}",
"contents": "${CONTENTS}"
}
EOF'
Here are the additional reference to Elevation Profile
Hope this helps.
- Edward