使用WinSCP和命令提示符时的批处理文件 [英] Batch file when using WinSCP and command prompt

查看:1695
本文介绍了使用WinSCP和命令提示符时的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个脚本,它调用WinSCP,连接SFTP会话,将一组文件从本地服务器传输到远程服务器,关闭连接,然后将本地文件移动到存档。另一个可接受的解决方案是将文件复制到存档,然后从源目录中删除。

I am currently writing a script that calls WinSCP, connects an SFTP session, transfers a group of files from a local server to a remote server, closes the connection, then moves the local file to an archive. An alternate acceptable solution would be to copy the file to archive and then delete it from the source directory.

我遇到的问题是,我可以获得WinSCP打开,连接和传输文件,但之后,命令被忽略,我无法自动关闭,文件移动或复制和删除和关闭命令提示符。什么是最好的方法做到这一点?

The problem I am having is that I can get WinSCP to open, connect and transfer the files, but after that the commands are ignored and I am unable to automate the connection close, file move or copy and the deletion and closing of command prompt. What is the best way to do this?

我的 FTP.bat 文件连接会话并调用脚本 -

My FTP.bat file that connects the session and calls the script -

"C:\Program Files\WinSCP\WinSCP.exe" /console /command "lcd d:\bofa_ftp\out" /script=script.txt savedsession@winscpname.com

我放置文件并关闭连接的脚本文件 -

My script file that puts the file and closes the connection -

option batch abort
option confirm off
option exclude script.txt
put *.txt
close



当添加任何命令到bat或脚本时,

When I add any commands to either the bat or the script they are ignored.

推荐答案

关闭后的命令绝对不会被忽略。您的问题可能是,您正试图将Windows命令放到WinSCP脚本。请注意,在WinSCP中没有用于移动本地文件的命令。

Commands after close are definitely not ignored. Your problem might be that you are trying to put Windows commands to WinSCP script. Note that there are no commands in WinSCP to move local files.

这篇关于使用WinSCP和命令提示符时的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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