I want to assign the following multiple line string value to a variable in a shell script with the the exact indentations and lines.
Usage: ServiceAccountName LogFile
Where:
ServiceAccountName - credentials being requested.
LogFile - Name of the log file
I have been trying to do this following all the suggestions in: How to assign a string value to a variable over multiple lines while indented? But with no result. Please suggest.
REASON="$(cat <<-EOF
Usage: ServiceAccountName LogFile
Where:
ServiceAccountName - credentials being requested.
LogFile - Name of the log file
EOF
)"
echo "$REASON"
Here is my script:
GetBatchCredentials.sh
if [ $# -ne 2 ]
then
# RETURN INVALID USAGE
GetBatchCredentials_Result="Error"
GetBatchCredentials_Reason="$(cat <<-EOF
Usage: ServiceAccountName LogFile
Where:
ServiceAccountName - credentials being requested.
LogFile - Name of the log file
EOF
)"
else
//coding...
fi
This scripts is called from the following script:
. /www/..../scripts/GetBatchCredentials.sh arg1 arg2
if [ "$GetBatchCredentials_Result" != "Success" ]
then
echo "Error obtaining FTP Credentials"
echo "$GetBatchCredentials_Reason"
ret=1
else
echo "Obtained Credentials"
fi