繁体   English   中英

我无法通过批处理脚本将多个文件上传到FTP

[英]I can't upload a multiple files to FTP by batch script

我无法通过我制作的批处理文件将多个文件上传到某些FTP。

另外,我想从该本地目录上载所有文件。

编码:

ftp -s:"C:\automation\fileup.bat" MYSERVER.COM
USERNAME
PASSWORD
ascii
cd "/public_html/reports/"
lcd "C:\automation\tests\HtmlReporter"
mput *
close
quit

错误:

C:\automation>ftp -s:"C:\automation\fileup.bat" MYSERVER.COM
Connected to server26.000webhost.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 12 of 500 allowed.
220-Local time is now 07:03. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
User (MYSERVER.COM:(none)):
331 User USERNAME OK. Password required

230-OK. Current restricted directory is /
230-109 files used (1%) - authorized: 10000 files
230 14084 Kbytes used (0%) - authorized: 1536000 Kb
ftp> ascii
200 TYPE is now ASCII
ftp> cd "/public_html/reports/"
250 OK. Current directory is /public_html/reports
ftp> lcd "C:\automation\tests\HtmlReporter"
Local directory now C:\automation\tests\HtmlReporter.
ftp> mput *
mput 000500de-0092-0095-00d9-00a100f000f7.json? close
mput 00090020-0041-007c-00db-00b9003c0085.json? quit
ftp>

我尝试上传的文件:

在此处输入图片说明

使用prompt命令可关闭转移确认提示:

切换提示模式的开和关。

没有它,tje ftp将在脚本中使用以下命令(在您的情况下为closequit )作为答案。 由于它们不是y ,因此跳过了传输。


具有相同效果的另一个选项是在ftp命令行上使用-i开关:

-i :在多次文件传输期间禁用交互式提示。

应该这样做:

ftp -i -s:"C:\automation\fileup.bat" MYSERVER.COM

然后在您的脚本中像这样结束它:

mput *  
bye

FTP命令允许发送多个文件,但是如果我们要自动创建和传输目录和子目录,则可以使用ncftp 步骤如下:

  • 如果您使用Windows PC通过FTP将文件传输到Linux服务器,请下载适用于Microsoft Windows的NcFTP Client 3.2.6。
  • 由于您正在尝试通过批处理文件进行发送,因此我们可以使用ncftpput命令,该命令是用于脚本的Internet文件传输程序
  • 创建批处理文件(例如,ncftpupload.bat)并提供为:

句法:

ncftpput -u username -p password -m -R SERVER_IP_ADDRESS /remote_directory local_directory\*

例:

ncftpput -u ftpuser1 -p ftppass1 -m -R 192.168.1.10 /var/www C:\public_html\*

使用的开关是:

-u: FTP username
-p: FTP password
-m: Attempt to make the remote destination directory before copying.
-R: Recursive mode; copy whole directory trees

暂无
暂无

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

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