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

后端 未结 3 712
傲寒
傲寒 2020-12-20 07:54

I can\'t succeed to upload a multiple files to some FTP by batch file I made.

Also, I want to upload all files from this local directory.

The code:

相关标签:
3条回答
  • 2020-12-20 08:01

    FTP command allows sending multiple files but if we want directories and sub-directories auto created and transferred then alternatively, we can use ncftp. Steps below:

    • Download NcFTP Client 3.2.6 for Microsoft Windows if you're using Windows PC for transferring files to Linux Server via FTP
    • Since, you're trying to send via batch file, we can use ncftpput command which is Internet file transfer program for scripts
    • Create batch file (say, ncftpupload.bat) and provide as:

    Syntax:

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

    Example:

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

    The switches used are:

    -u: FTP username
    -p: FTP password
    -m: Attempt to make the remote destination directory before copying.
    -R: Recursive mode; copy whole directory trees
    
    0 讨论(0)
  • 2020-12-20 08:18

    Use the prompt command to turn off transfer confirmation prompts:

    Toggles prompt mode on and off.

    Without it, tje ftp uses the following commands in the script (the close and the quit in your case) as answers. As they are not y, the transfer is skipped.


    Another option with the same effect is using the -i switch on the ftp command-line:

    -i : Disables interactive prompting during multiple file transfers.

    0 讨论(0)
  • 2020-12-20 08:20

    This should do it:

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

    And in your script, end it like this:

    mput *  
    bye
    
    0 讨论(0)
提交回复
热议问题