【发布时间】:2016-07-20 23:06:27
【问题描述】:
我正在尝试登录其中一台远程服务器 (Box1) 并尝试读取远程服务器 (Box1) 上的一个文件。 其中包含另一台服务器(Box2)的详细信息,基于该详细信息,我必须返回本地服务器并通过 ssh 连接到另一台服务器(Box2)以进行一些数据处理。等等……
ssh box1.com << EOF
if [[ ! -f /home/rakesh/tomar.log ]]
then
echo "LOG file not found"
else
echo " LOG file present"
export server_node1= `cat /home/rakesh/tomar.log`
fi
EOF
ssh box2.com << EOF
if [[ ! -f /home/rakesh/tomar.log ]]
then
echo "LOG file not found"
else
echo " LOG file present"
export server_node2= `cat /home/rakesh/tomar.log`
fi
EOF
但我没有在本地机器上获得“server_node1”和“server_node2”的值。
任何帮助将不胜感激。
【问题讨论】:
-
您在
[[ ! -f ]]中有/home/rakesh,但在cat中有/home/rt9419。您真的是在检查一个文件是否存在,然后故意检索另一个文件,还是其中一个错误? -
哎呀我的坏!纠正事情。谢谢
标签: bash shell unix ssh scripting