使用 WinSCP 上传后文件不存在于 SFTP 目录中
Files are not present in SFTP directory after upload using WinSCP
我需要一个使用 WinSCP 将文件复制到 SFTP 服务器的脚本。
- 连接
- 复制文件
- 如果复制成功则删除本地文件
- 断开连接
到目前为止我的 txt 文件:
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# open user:password@example.com
# Connect
open sftp://***:***@***.fr/ -hostkey=*
# Force binary mode transfer
option transfer binary
# Interface 1
cd /tracks
lcd "Y:\"
#Copie des données en local
get *.txt
#Envoie de données sur le serveur
put *.*
#Effacement des données
put -delete "Y:\*.txt"
# Interface 2
cd /trackm
lcd "Y:\"
#Copie des données en local
get *.tar-gz*
#Envoie de données sur le serveur
put *.*
#Effacement des données
put -delete "Y:\*.tar-gz*"
#Disconnect
#close
#Exit WinSCP
#exit
到目前为止我的 bat 文件:
@echo off
"D:\WinSCP\WinSCP.com" /log="D:\logfile.log" /ini=nul /script="D:\script_test.txt"
到目前为止它没有上传文件,但它删除了它们。
你的脚本有点意思。
如果您想要一个将所有 Y:\*.txt
文件移动到 /tracks
并将所有 Y:\*.tar-gz*
文件移动到 /tracksm
的简单脚本,请替换 [=15] 之后的所有脚本=]命令:
put -delete Y:\*.txt /tracks/
put -delete Y:\*.tar-gz* /trackm/
exit
参见 documentation of put
command。
尽管看起来原始脚本非常丑陋且效率低下,但它可能完成了它的工作。
根本问题是您的服务器可能会对上传的文件进行一些处理,并在处理后删除或移走文件。
这是处理文件(与存储文件相反)的服务器的常见行为。
请参阅 WinSCP 常见问题 Why is uploaded file not showing in a remote directory or showing with a different name?
我需要一个使用 WinSCP 将文件复制到 SFTP 服务器的脚本。
- 连接
- 复制文件
- 如果复制成功则删除本地文件
- 断开连接
到目前为止我的 txt 文件:
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# open user:password@example.com
# Connect
open sftp://***:***@***.fr/ -hostkey=*
# Force binary mode transfer
option transfer binary
# Interface 1
cd /tracks
lcd "Y:\"
#Copie des données en local
get *.txt
#Envoie de données sur le serveur
put *.*
#Effacement des données
put -delete "Y:\*.txt"
# Interface 2
cd /trackm
lcd "Y:\"
#Copie des données en local
get *.tar-gz*
#Envoie de données sur le serveur
put *.*
#Effacement des données
put -delete "Y:\*.tar-gz*"
#Disconnect
#close
#Exit WinSCP
#exit
到目前为止我的 bat 文件:
@echo off
"D:\WinSCP\WinSCP.com" /log="D:\logfile.log" /ini=nul /script="D:\script_test.txt"
到目前为止它没有上传文件,但它删除了它们。
你的脚本有点意思。
如果您想要一个将所有 Y:\*.txt
文件移动到 /tracks
并将所有 Y:\*.tar-gz*
文件移动到 /tracksm
的简单脚本,请替换 [=15] 之后的所有脚本=]命令:
put -delete Y:\*.txt /tracks/
put -delete Y:\*.tar-gz* /trackm/
exit
参见 documentation of put
command。
尽管看起来原始脚本非常丑陋且效率低下,但它可能完成了它的工作。
根本问题是您的服务器可能会对上传的文件进行一些处理,并在处理后删除或移走文件。
这是处理文件(与存储文件相反)的服务器的常见行为。
请参阅 WinSCP 常见问题 Why is uploaded file not showing in a remote directory or showing with a different name?