0

我正在尝试使用 Plink 在远程服务器上运行命令。本地和远程机器都是 Windows。虽然我可以使用 Plink 连接到远程机器,但我无法使用“-m 文件”选项。我尝试了以下三种方法,但无济于事:

尝试1:

plink.exe -ssh -pw mypwd john.doe@server -m file.txt

输出:

Could not chdir to home directory /home/john.doe: No such file or directory
dir: not found

'file.txt' 只包含一个命令,即 dir

尝试2:

plink.exe -ssh -pw mypwd john.doe@server dir

输出:

Could not chdir to home directory /home/john.doe: No such file or directory
dir: not found

尝试3:

plink.exe -ssh -pw mypwd john.doe@server < file.txt

在这种情况下,我得到以下输出:

Using username "john.doe".

                            ****USAGE WARNING****

This is a private computer system. This computer system, including all
..... including personal information, placed or sent over this system
may be monitored.

Use of this computer system, authorized or unauthorized, constitutes consent
... constitutes consent to monitoring for these purposes.


dirCould not chdir to home directory /home/john.doe: No such file or directory
Microsoft Windows [Version x.x.xxx]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Program Files\OpenSSH>  

收到上述提示后,它挂起。在这方面有什么帮助吗?

4

3 回答 3

1

您正在 Windows 服务器上通过 Cygwin 使用 OpenSSH。

Cygwin 在 Windows 上模拟 Unix 环境。

所以你必须使用 Unix,而不是 Windows 命令(例如mvnot moveor rename

而且您需要使用类 Unix 路径,而不是 Windows 路径(特别是正斜杠)。

此外,您的服务器似乎配置错​​误。


无法 chdir 到主目录 /home/john.doe:没有这样的文件或目录

这可能是一个错误配置的帐户。该错误与您正在执行的命令无关。

于 2015-01-29T07:38:34.557 回答
1

似乎plink -m工作正常:来自 file.txt 的命令正在发送到服务器。

但是,您的 SSH 服务器正在运行一个bash不理解您正在使用的命令(例如movedir. 因为bash实现了这些命令的自己的版本(mvls,分别)。正如您所发现的,您需要cmd.exe /C在 Windows 目录之外运行 SSH 服务器才能正确解释命令的含义。另一种选择是直接使用bash命令的版本。

于 2014-09-08T23:11:04.680 回答
1

现在正在工作。

plink -ssh -pw xxx john.doe@server cmd.exe /c move c://sample//jd//file.txt c://test//

于 2010-07-02T09:15:07.360 回答