3

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

Currently it will allow me to input the IP, connect to the server and open a specific file, but every time it tries to connect to copy files it says invalid directory or incorrect 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 when the ftp server will be different almost every time its used

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • What are you typing exactly? – Andre Kampling Jul 31 '17 at 11:16
  • Well, what I pasted in the original comment was what I was attempting, i know xcopy wont work for FTP, but because of the nature of the devices used where I work connecting to the FTP server for them is a pain in the ass. For example the full FTP link above with the IP address in place on %PDT%, If I paste it in explorer it connects immediately with no prompt to login, but programs like filezilla will not connect, even though the geniuses in my office repeatedly tell us to use it after they blocked it... – Tyler cummings Aug 01 '17 at 03:53
  • The part under :DB is the only part not working, im just trying to copy release files from one server to the devices itself since we dont have an automated program for it – Tyler cummings Aug 01 '17 at 03:55
  • So does the answer by @Hacker help you or not? Do you need any more information? – Martin Prikryl Aug 01 '17 at 06:32

1 Answers1

2

You could do it like this:

to download the file:

@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 the file:

@echo off

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

ftp -s:temp.txt %ip%
del temp.txt
HackerNCoder
  • 276
  • 1
  • 9