Bash变量始终为空

Sb *_*Lon 0 linux bash heredoc

以下bash脚本的结果是输出中的"空行"

ssh dev@my_service <<EOF
  START_SERVICE_TIME_IS_UP=124
  echo $START_SERVICE_TIME_IS_UP
  exit  
EOF
Run Code Online (Sandbox Code Playgroud)

无法理解为什么.我希望在输出中看到"124".远程服务器正在运行Red Hat linux.

Bar*_*mar 7

除非引用here-doc,否则here-doc中的变量将由本地shell进行扩展.将结束标记放在引号中引用here-doc.

ssh dev@my_service <<'EOF'
  START_SERVICE_TIME_IS_UP=124
  echo $START_SERVICE_TIME_IS_UP
  exit  
EOF
Run Code Online (Sandbox Code Playgroud)