[英]How to call ssh from script(csh/tcsh)?
I have different servers with different IPs with I can ssh in any servers and get my database intact (I don't know how, I am just an user). 我有具有不同IP的不同服务器,可以在任何服务器中使用ssh并保持数据库完整(我不知道如何,我只是一个用户)。 I have written one script to move from one server to other server using ssh in the same directory where I was in first server. 我编写了一个脚本,使用ssh在第一台服务器所在的同一目录中从一台服务器移动到另一台服务器。
Here you can see final command that if I type will work: 在这里,您可以看到最终的命令,如果我键入该命令,它将起作用:
ssh -X usr@192.168.1.xyz -t 'cd /home/usr/regression && exec /bin/csh'
Now here a part of small script: 现在这里是小脚本的一部分:
set path = $PWD
set user = $1
set cmd = "ssh -X $user@192.168.$ip3.$ip4 -t 'cd $path && exec $SHELL'"
echo $cmd;
$cmd;
Since It is csh/tcsh script I just want to run 由于它是csh / tcsh脚本,所以我只想运行
$cmd $ CMD
command but it give this message: 命令,但它给出以下消息:
ssh: Command not found. ssh:找不到命令。
While If I copy,paste and run the final command that I am getting with: 如果复制,请粘贴并运行获得的最终命令:
echo "$cmd"
Like : 喜欢 :
ssh -X usr@192.168.1.xyz -t 'cd /home/usr/regression && exec /bin/csh' ssh -X usr@192.168.1.xyz -t'cd / home / usr / regression && exec / bin / csh'
Then It works fine. 然后它工作正常。
The path
variable in csh is a magic array tied to the PATH
environment variable. csh中的path
变量是绑定到PATH
环境变量的魔术数组。 When you changed it, you lost your original PATH
. 更改后,您将失去原始的PATH
。 Not just ssh, but all external commands will fail after that because none of them can be found, unless they are in $PWD
which is your new PATH
. 不仅是ssh,而且所有外部命令将在此之后失败,因为找不到任何外部命令,除非它们位于$PWD
,这是您的新PATH
。
Call your path
variable something else. 将您的path
变量称为其他名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.