

linux shell脚本 ssh 获取变量问题
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 获取变量问题
写了个部署脚本,需要从当前服务器远程到其他服务器完成部署工作,代码如下:
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中取不到内容,是写法有问题吗?
Recommend
-
13
shell 获取脚本的绝对路径 2021-06-08 22:10:00 https://www.cnblogs.com/FlyFive/p/3640267.html 常见的一种误区,是使用 pwd 命令
-
9
更新于 2021/08/14 | 创建于 2021/08/13 如何在shell脚本设置当前shell的环境变量 Your shell process has a copy of the pa...
-
5
19 November 2021 / Shell Script #Shell 脚本的特殊变量 Shell脚本中有一些特殊的变量: $0 当前脚本的文件名 $n 传递给脚...
-
10
Linux shell脚本使用while循环执行ssh的注意事项 浏览:6016次 出处信息 如果要使用ssh批量登录到其它系统上操...
-
10
Bash Shell 脚本新手指南(一) | Linux 中国如标题所示,本文将涵盖面向初学者的 Bash Shell 脚本知识。来源:https://lin...
-
8
Blog My Life关于shell中使用ssh的变量问题发表于2020-11-06|更新于2020-11-06|it阅读量:6在shell中使...
-
11
Mac如何在shell脚本当中获取时间 | PPmoon's Blog Mac如何在shell脚本当中获取时间 Posted on 2019-08-26 in shell ...
-
5
shell脚本编程-获取系统信息 原创 #!/bin/bashRED="\E[1;31m"GREEN="echo -e \E[1;32m"END="\E[0m"...
-
7
如果你使用编程语言编写过程序,那么一定接触过变量。而在 bash 脚本的编写时,变量也是一个很重要的概念。今...
-
12
Bash 特殊变量在脚本编程中起着重要的作用,用于获取脚本自身的信息、命令的执行状态、命令行参数等。之前我们曾介绍过 Bash 特殊变量 $? ,它表示最后一个命令或最近执行的进程的状态,也称为退出代码。在本教程中,我们将在 Linux 说明...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK