5

关于shell中使用ssh的变量问题

 2 years ago
source link: http://blog.colorccm.com/2020/11/06/it/shell_ssh/
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.
neoserver,ios ssh client
Blog My Life

关于shell中使用ssh的变量问题

发表于2020-11-06|更新于2020-11-06|it
阅读量:6

在shell中使用ssh对远程服务器进行操作,对于变量需要特殊标记。

shell
localparam="hello"
ssh user@ip <<EOF
echo ${localparam}
remoteparam="world"
echo \${remote} #远程的变量需要用\$
EOF

例如需要ssh到远程服务器上操作,并且有for循环操作的,就需要注意远程变量的问题

shell
ssh user@ip <<EOF
for i in $(echo test.txt)
do
echo ${i} #无法正确显示
echo \${i} #可以正确显示
done
EOF

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK