6

linux shell脚本 ssh 获取变量问题

 2 years ago
source link: https://www.oschina.net/question/4986706_2323492
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

linux shell脚本 ssh 获取变量问题

osc_52211976 发布于 昨天 18:11

写了个部署脚本,需要从当前服务器远程到其他服务器完成部署工作,代码如下:

ssh -T $HOST<<EOF
ID=test1
echo "ssh 第一次 ID为"\$ID
EOF

ssh -T $HOST<<EOF
ID=test2
echo "ssh 第二次 ID为"\$ID
EOF

在第一次的代码中定义了ID变量,通过\$ID 能取到内容,但是在第二次的ssh中取不到内容,是写法有问题吗?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK