Search code examples
batch-fileftpserver-side

Batch script to FTP folders and files to multiple servers


Helo, Im trying to send zip folder to multiple servers at one time. Im thinking to put a list which include servers IP (windows servers). But i dont have any idea on how to implement it. Please assist thank you. Assuming that all servers use same password and username with same folder structure.

The algorithm as:

ftp (serverlist.txt) << how can i put serverlist with loop until file send to all servers in the list? 
%username% 
%passsword% 
cd %dpath% 
send %file%.zip 
quit

Solution

  • FOR is your friend. Read HELP FOR and try this in the command line

    FOR %a  in (10.7.8.1 172.16.9.11 192.168.2.6) do @echo ftp -s:sendzip.scr %a
    

    if instead of having the server list in the command line, you want it in an external text file

    FOR /F %a in (servers.txt) do @echo ftp -s:sendzip.scr %a