这是我的代码:
echo "`${BOLD}` ***** Checking CoreFile Creation *****`${UNBOLD}`"
echo "========================================================"
IFS='|'
cat configMachineDetails.txt | grep -v "^#" | while read MachineType UserName MachineName
do
export CHK_COREFILE=`ssh -f -T ${UserName}@${MachineName} ls ~/corefiles | wc -l|sed 's/ //g'`
if [ $CHK_COREFILE -gt 0 ]
then
echo "CHK_COREFILE $CHK_COREFILE number of core files are created"
echo " "
export CHK_COREFILES_NAME=`ls -lrt ~/corefiles`
echo " Name of the Files $CHK_COREFILES_NAME "
echo "MachineType $MachineType UserName $UserName MachineName $MachineName"
echo "-----------------------------------------------------"
fi
done
SSH到不同的机器后ls
到运行代码的机器的路径。因此它说没有找到路径。
export CHK_COREFILE=`ssh -f -T ${UserName}@${MachineName} ls ~/corefiles | wc -l|sed 's/ //g'`
如何处理?使用(ksh)Solaris。
答案 0 :(得分:1)
设置ssh
的{{1}}命令仅在远程服务器上运行自己的行,该行不包括CHK_COREFILE
。简单的解决方案是将ls -lrt ~/corefiles
分配更改为
export CHK_COREFILES_NAME=`ssh -f -T ${UserName}@${MachineName} ls -lrt ~/corefiles`