我正在尝试将Debian Bash脚本转换为Linux Busybox sh脚本。我一直在尝试转换以下命令:
read
问题是echo "RESULTS: $MESSAGE" >> $LOGFILE
sendmail -S smtp.server.com -f "$FROM" "$RECIPIENTS" <<EOF
subject:$SUBJECT
from:$FROM
$MESSAGE
EOF
的-d选项不适用于Busybox。如何将变量(在这种情况下为$ MESSAGE)设置为包含多行包含其他变量值的多行字符串?
输出MESSAGE进入日志文件和sendmail发送的消息中:
type MyCustomObj<Key extends string | number, Value, Rest = {}> =
Key extends string ? { [key: string]: Value } & Rest: { [key: number]: Value } & Rest;
答案 0 :(得分:1)
最简单的答案是不使用读取。
MESSAGE=$(cat <<EOM
Return code: $retn_code
Start of backup: $DATESTART
End of backup: $DATEEND
$(df -h | grep '/share/USB')
EOM
)
MESSAGE=$( printf "%s\n%s\n%s\n%s\n" \
"Return code: $retn_code" \
"Start of backup: $DATESTART" \
"End of backup: $DATEEND" \
"$(df -h | grep '/share/USB')" \
)
答案 1 :(得分:0)
在任何shell中都不需要特殊的命令;只是常规作业。
message="Return code: $retn_code
Start of backup: $DATESTART
End of backup: $DATEEND
$(df -h | grep '/share/USB')
"