FTP via CMD for different servers

So I am trying to write a small batch program to copy files over ftp to another device The problem is that the devices I copy to are all different servers, but the information I copy stays the same. How can I write this, when I open the batch program, I specify the IP address of the device, and the package will automatically connect to the server and copy the directories or files that I need to copy.

Currently, this will allow me to enter the IP address, connect to the server and open a specific file, but every time it tries to connect to copy files it says an invalid directory or invalid server.

:Log
set /p PDTFTP= Enter PDT IP Address: 
start "ftp://admin:2p0d0t7@%PDTFTP%/pub/IPSM/fds/log/PDTApplicationLog.txt"

:DB 
set /p PDTFTP= Enter PDT IP Address: 
xcopy "C:\test.txt" "ftp://admin:2p0d0t7@%PDTFTP%/pub/IPSM/fds/"

      

Is there a way to do this where the ftp server will be different almost every time it is used

+3


source to share


1 answer


You can do it like this:

to get a file (on a server that doesn't have a file, use this (to download from another server)):

@echo off
set /p ip=IP:
echo username> temp.txt
echo password>> temp.txt
echo get filetoget>> temp.txt
echo quit>> temp.txt

ftp -s:temp.txt %ip%
del temp.txt

      



to upload a file (on the server that has the file is used (to upload to another server)):

@echo off
set /p ip=IP:
echo username> temp.txt
echo password>> temp.txt
echo put fileupload>> temp.txt
echo quit>> temp.txt

ftp -s:temp.txt %ip%
del temp.txt

      

+1


source







All Articles