简体   繁体   English

无法在Windows上使用FTP脚本和批处理传输文件

[英]Can't transfer files using FTP script and batch on Windows

I have a folder with PDF files locally on hard disk and I want to upload files from this folder to an FTP server. 我在硬盘上有一个本地包含PDF文件的文件夹,我想将文件从该文件夹上传到FTP服务器。

So I created a batch file that should upload PDF files to the FTP server. 因此,我创建了一个批处理文件,该文件应将PDF文件上传到FTP服务器。 Everything seems to work fine and the console window displays File successfully transferred , but actually no file really uploaded. 一切似乎工作正常,控制台窗口显示“ File successfully transferred ,但实际上没有真正上传的文件。

The FTP script content: FTP脚本内容:

open
000.000.000.000  -- not the real ftp server ip lol 
bla@nirlatpro.com
PASSWORD
mput c:\Batch\*.pdf
quit

Command window with output on running this script: 运行此脚本时输出的命令窗口:

运行脚本时在控制台窗口中输出行

It looks like it works, but no file is actually uploaded. 看起来可行,但实际上没有文件上传。

What is even more strange is if I connect to FTP using GUI application and drag the files, it does work and all the files are uploaded to the server. 更奇怪的是,如果我使用GUI应用程序连接到FTP并拖动文件,它确实可以工作并且所有文件都已上载到服务器。

summary: - It's works fine if i'm using windows explore and dragg the files. 摘要:-如果我使用Windows探索并拖动文件,效果很好。 - It's not uploading the files if i'm using cmd commands or batch script with ftp file, even if the console window displays 'File successfully transferred' -如果我使用cmd命令或带有ftp文件的批处理脚本,则不会上载文件,即使控制台窗口显示'File successfully transferred'

it was a permissions problem apparently the ftp server does not allowing to copy files in to the root directory / 这显然是一个权限问题,ftp服务器不允许将文件复制到根目录/

console window display it "Current restricted directory is / " 控制台窗口将其显示为“当前受限目录为/”

I too Faced a similar problem downloading a file from ftp through command line, But every time my request was rejected and my connection was not established. 我也面临着类似的问题,通过命令行从ftp下载文件,但是每次我的请求被拒绝并且我的连接都没有建立时。 After a thorough research i found the ti need to do settings in the IIS for ftp. 经过深入研究,我发现ti需要在IIS中为ftp进行设置。

Steps: 脚步:

1) Set your IIS Server on. 1)设置您的IIS服务器。 a:Goto control panel-->Programs&Features-->Turn windows Features on or off-->Internet Information Services. a:转到控制面板->程序和功能->打开或关闭Windows功能-> Internet信息服务。 b: Expand the Internet Information services-->Check FTP services-->Expand FTP Server-->FTP Service (Check it)-->press OK. b:展开Internet信息服务->检查FTP服务->展开FTP服务器-> FTP服务(检查它)->按OK。

2)Open IIS Manager(win+r-->inetmgr) a: Select FTP authentication-->Enable Anonymous Authentication or Base Authentication (as per your requirement). 2)打开IIS管理器(win + r-> inetmgr)a:选择FTP身份验证->启用匿名身份验证或基本身份验证(根据您的要求)。 b: Select FTP Authorization-->Select All users, give permissions (read or write or both) & press ok. b:选择“ FTP授权”->“选择所有用户”,授予权限(读或写或同时授予两者)并按OK。 c) Open FTP Directory Browsing select MS-DOS for windows Server or Unix for Unix server. c)打开“ FTP目录浏览”,对于Windows Server选择MS-DOS,对于Unix服务器选择Unix。

3) Finally goto Services.msc(win+r-->'services.msc')-->MicrosoftFTPServices-->restart. 3)最后转到Services.msc(win + r->'services.msc')-> MicrosoftFTPServices->重新启动。

Now goto your command prompt and write your respective code for ftp it will work. 现在转到命令提示符并为ftp编写您各自的代码,它将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM