将文件从 Windows 复制到远程 Linux 系统的 BAT 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6162366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:24:48  来源:igfitidea点击:

BAT script to copy files from Windows to remote Linux systems

windowsbatch-filewinscp

提问by devnull

Is there anyway to copy files from Windows machine to a remote Linux machine with a DOS command/other command-line tool (by specifying username and password in the command). I normally do this using WinSCP and would like to write a script (BAT) to automate this.

无论如何,是否可以使用 DOS 命令/其他命令行工具(通过在命令中指定用户名和密码)将文件从 Windows 机器复制到远程 Linux 机器。我通常使用 WinSCP 执行此操作,并想编写一个脚本 (BAT) 来自动执行此操作。

采纳答案by Uwe Keim

You could use the command line version of PuTTY, pscp.exe.

你可以使用的命令行版本腻子pscp.exe

回答by Michael Berkowski

Download a copy of pscp.exe(the PuTTY scp companion). If you have setup SSH keys on the Linux server, which you can do with PuTTY on Windows, you can setup password-less copy to Linux machines from Windows.

下载pscp.exe(PuTTY scp 伴侣)的副本。如果您在 Linux 服务器上设置了 SSH 密钥,您可以在 Windows 上使用 PuTTY 进行设置,那么您可以设置从 Windows 到 Linux 机器的无密码复制。

回答by Martin Prikryl

WinSCP scripting command-lineto upload a file is like:

上传文件的WinSCP 脚本命令行如下:

winscp.com /command "open sftp://[email protected]/" "put d:\www\index.html" "exit"

See the guide to WinSCP scripting.

请参阅WinSCP 脚本编写指南



Easier is to use a Generate transfer code functionto have WinSCP GUI generate a script (or even a complete batch file) for a transfer.

更简单的方法是使用生成传输代码功能让 WinSCP GUI 生成用于传输的脚本(甚至完整的批处理文件)。

Generate transfer code dialog

生成传输代码对话框

回答by ralphtheninja

Install cygwin and you can use scp, ssh etc just like you would on linux. Besides, you can use ordinary bash scripts instead of crappy bat-files.

安装 cygwin,您可以像在 linux 上一样使用 scp、ssh 等。此外,您可以使用普通的 bash 脚本而不是蹩脚的 bat 文件。