[英]Executing local script/command on remote server
I have a command that I want to run on machine B from machine A. If I run the command on machine B locally, it works fine. 我有一个要从计算机A在计算机B上运行的命令。如果我在本地计算机B上运行该命令,则可以正常运行。
Here is the command: 这是命令:
for n in `find /data1/ -name 'ini*.ext'` ; do echo cp $n "`dirname $n `/` basename $n
.ext`"; done
From machine A, I issue this command 从机器A,我发出此命令
ssh user@machineB for n in `find /data1/ -name 'ini*jsem'` ; do echo cp $n "`dirname $n `/` basename $n .jsem`"; done
But I get error syntax error near unexpected token do
但是我
syntax error near unexpected token do
收到错误syntax error near unexpected token do
What is wrong? 怎么了? I think it has something to do with double quotes, single quotes, semi colon because executing command
ssh user@machineB ls
works fine. 我认为这与双引号,单引号和半冒号有关,因为执行命令
ssh user@machineB ls
可以正常工作。 So not issue of authentication or something else. 因此,不会发出身份验证或其他问题。
Thanks 谢谢
将您的代码放在脚本myScript.sh
并执行,就像ls一样: ssh user@machineB myScript.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.