如何使用ssh执行远程脚本

How to execute a remote script using ssh

我知道我可以找到这个问题的多个答案,但我对结果有疑问。

我有一台装有脚本的 Windows PC 和一台必须使用 ssh 启动脚本的 Linux PC。

我看到的问题是,出于某种原因,它使用 Linux 环境来 运行 脚本而不是 Windows 环境。这是预期的吗?如果是,我如何启动远程脚本(来自 Linux)并仍然使用 Windows 环境?

Linux: Python 2.7
Windows: Python 3.4
我的例子:
我是 运行ning:ssh user@host "WINDOWS_PYTHON_PATH Script.py arg1 arg2 arg3",它在复制命令
时内部失败 我不能 运行 ssh user@host "Script.py arg1 arg2 arg3" 因为 运行 脚本会因为 python 版本而失败。

我 运行 Windows 中的命令使用相同的语法 "Script.py arg1 arg2 arg3" 并且有效。

看起来它正在使用 Linux 环境到 运行 脚本。我想 运行 Windows 上的脚本,不管是谁触发的。我怎样才能做到这一点?

scp user@host:/PATH_YOUR_SCRIPT/Script.py Script.py;Script.py arg1 arg2 arg3

我的问题的解决方案是在脚本调用前使用 PATH=/cygdrive/c/WINDOWS/system32:/bin cmd /c,例如:ssh user@host "PATH=/cygdrive/c/WINDOWS/system32:/bin cmd /c script"。这将 运行 在 Windows 中使用的脚本环境

在我的例子中,问题是脚本在 cygwin 环境下 运行 而我想在 Windows 环境中成为 运行。