简体   繁体   English

在远程服务器上执行本地脚本/命令

[英]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.

相关问题 在远程服务器上执行Shell脚本::提供sqlplus:命令未找到 - Executing a Shell Script on Remote Server :: Gives sqlplus: command not found 在远程服务器上执行两个命令,并使用shell脚本将输出存储到本地服务器 - Executing two command at remote server and storing the output to local server using shell scripting 在远程服务器上执行命令行命令 - Executing command line commands on a remote server 如何使用参数在远程服务器中执行本地脚本 - how to execute an local script in remote server with parameters 使用Java使用Windows和Linux将本地文件复制并执行到远程服务器 - Copying and executing local files to a remote server with windows and linux using java 将ls命令的结果保存在本地计算机上的远程sftp服务器中 - save the result of ls command in the remote sftp server on local machine 从Shell脚本在另一台Linux服务器上远程执行命令 - Executing command remotely on another linux server from a shell script Python执行远程ssh命令 - Python Executing remote ssh command 如何使用 nohup 通过 ssh 在远程服务器上执行本地 bash 脚本 - How to execute a local bash script on remote server via ssh with nohup 如何运行脚本以将日志从远程服务器复制到本地 - How to run script to copy logs from remote server to local
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM