小编Ais*_*war的帖子

我想使用在 SSH 会话中声明的变量在我的 shell 脚本中本地使用

每当我尝试使用在我的 SSH 会话中声明的变量时,它都会给我空白输出。这是我尝试执行的代码:

ssh -T host <<\HERE
export usage1=$(df -h |grep /nas/infa|sed s/%//g| awk '{printf("%d\n",$4)}');
echo $usage1
HERE
echo $usage1
Run Code Online (Sandbox Code Playgroud)

我能够在 SSH 会话中获得所需的输出,但是在 SSH 之外调用相同的变量时,它给我空白。

scripting ssh shell-script variable

2
推荐指数
1
解决办法
386
查看次数

标签 统计

scripting ×1

shell-script ×1

ssh ×1

variable ×1