首页 > 解决方案 > ksh 远程函数 ssh 调用另一个远程函数

问题描述

function test_me
{
sqlplus /nolog <<EOF
connect / as sysdba
oradebug dump systemstate 266
oradebug tracefile_name
EOF
}

function check_me 
{
ssh ${HST2} "$(typeset -f); test_me"
}

ssh ${HST1} "$(typeset -f); check_me"

函数 test_me 的定义在 HST1 上看起来不错,但在 EOF 附近被截断为 HST2,失败并出现不匹配的 <<

有没有人解决这个问题?

标签: sshksh

解决方案


有两件事可以简化这一点:

  1. 使用ProxyJump选项让ssh通过 HST1 处理与 HST2 的连接
  2. 通过标准输入提供脚本,sqlplus而不是尝试嵌入函数定义。

ssh -o ProxyJump=HST1 HST2 "sqlplus /nolog" <<EOF
  connect / as sysdba
  oradebug dump system state 266
  oradebug tracefile_name
EOF

推荐阅读