如何使用 SSH 远程运行脚本文件 [英] How to run a script file remotely using SSH

查看:65
本文介绍了如何使用 SSH 远程运行脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想远程运行脚本.但是系统无法识别路径.它抱怨没有这样的文件或目录".我用对了吗?

I want to run a script remotely. But the system doesn't recognize the path. It complains that "no such file or directory". Am I using it right?

ssh kev@server1 `./test/foo.sh`

推荐答案

反引号将在本地 shell 上运行命令并将结果放在命令行上.您所说的是执行 ./test/foo.sh 然后传递输出,就像我在此处的命令行输入一样".

Backticks will run the command on the local shell and put the results on the command line. What you're saying is 'execute ./test/foo.sh and then pass the output as if I'd typed it on the commandline here'.

尝试以下命令,并确保这是从远程计算机上的主目录到脚本的路径.

Try the following command, and make sure that thats the path from your home directory on the remote computer to your script.

ssh kev@server1 './test/foo.sh'

此外,脚本必须在远程计算机上.这实际上是将您登录到远程计算机,并将列出的命令作为您的 shell.您不能像这样在远程计算机上运行本地脚本(除非有一些我不知道的有趣技巧).

Also, the script has to be on the remote computer. What this does is essentially log you into the remote computer with the listed command as your shell. You can't run a local script on a remote computer like this (unless theres some fun trick I don't know).

这篇关于如何使用 SSH 远程运行脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆