无法通过ssh通过函数调用访问局部变量

时间:2018-08-09 09:36:03

标签: linux unix ssh

这是我正在尝试执行的代码:

#!/bin/bash

set -e -a

err_report() {
    echo "Error on line $1"
}

trap 'err_report $LINENO' ERR

IFS=$'\n'

value=($(cat builds.txt))

prevBuild=${value[0]}
prevBuildDir=$prevBuild
currentBuild=${value[1]}
currentBuildDir=$currentBuild

splitPrevBuild=(${prevBuild//./$'\n'})
splitcurrentBuild=(${currentBuild//./$'\n'})

prevBuildSR=${splitPrevBuild[2]}
prevBuildHF=${splitPrevBuild[3]}
prevBuildNum=${splitPrevBuild[4]}
currentBuildSR=${splitcurrentBuild[2]}
currentBuildHF=${splitcurrentBuild[3]}
currentBuildNum=${splitcurrentBuild[4]}

function change {
    cd ~/InstallationFiles/${currentBuildSR}/${currentBuildDir}/${currentBuild}extracted
}

change
pwd
ssh -T atao52@kvs-in-hsglap17.in.kronos.com <<-EOF
$(typeset -f)
change
pwd
echo hi
exit
EOF

它说如何像现在一样访问变量 cd:/ home / atao52 / InstallationFiles ////解压缩:没有这样的文件或目录

0 个答案:

没有答案