使用WinSCP命令上传文件到CentOS

Windows安装WinSCP

安装WinSCP,略过。

CentOS安装openssh-server

使用命令 yum list installed | grep openssh-server 查询是否安装过openssh-server,如果未安装,使用命令yum install openssh-server进行安装。

批处理与命令文件

批处理文件为upload.cmd,内容为:

winscp.exe /console /script=command.txt /log=log.txt

winscp.exe路径如果未加入到环境变量需要加上绝对路径,如果路径有空格,整个路径加上"";
/script=command.txt指定命令文件;
/log=log.txt为执行过程中产生的日志输出文件;
=号两边不能有空格;

命令文件为command.txt,内容为:

option confirm off
open 用户名:密码@远程服务器ip
put 本地文件或者目录(支持通配符) 服务器目录
close
exit

执行upload.cmd即可调用winscp上传文件到服务器。

参考

用WinSCP命令上传文件到Linux

猜你喜欢

转载自blog.csdn.net/xp178171640/article/details/119344789