How to specify FTP source and destination directories in a script task?

I am creating a script on the fly to ftp some files from a remote computer. I am creating a file which is then called from the command line with

ftp -s:filename proxy

      

where filename is the file I just created. The file has code similar to the following:

anonymous@ip address
username
prompt off
binary
cd c:\destination directory
mget c:\source directory\*.*
quit

      

This does not work. Also the following fails:

anonymous@ip address
username
prompt off
binary
cd c:\source directory
mput c:\destination directory
quit

      

Obviously I'm not very good at ftp. How, in what order, where in my file do I specify the location where I want the files to be placed (the target directory as well as where the ftp process was started from) and where I want the files to arrive (the ip address of the computer, at which has the files I want). Do I need to install the directory before starting the ftp process?

I am running this in an SSIS package and I am not using the SSID ftp task because I do not want to crash if no files are found. If there's nothing there, that's cool. If there is anything there, I need a copy.

(It worked in my development area, and now when I try to get files from the server that I really don't have access to other than ftp, I get nothing. See How to avoid SSIS FTP task from crashing when there are no files for download? for an earlier related question.)

Update: Both answers below, listing lcd and cd, are correct. However, my example still failed until I replaced the backslash with a forward slash. In other words, my final, working result looks like this:

anonymous@ip address
username
prompt off
binary
lcd /destination directory
cd /source directory
mget *.*
quit

      

+1


source to share


2 answers


In most ftp clients, you can set the working directory on the server with the cd command , and you set the working directory on the client with the lcd command .

But it is not clear to me what you are trying to do.



Are you trying to move or copy files that are on the ftp server to another location on the ftp server? As far as I know, you cannot do this from ftp. If you want to copy files from one folder on the ftp server to another, I trust you will get a copy on your local system and then re-upload them to the new folder. If you want to move files, you can use the rename command .

+1


source


Are you looking for LCD and CD where the LCD changes directory on your local computer? EG:



LCD c:\destination directory
mget c:\source directory\*.*

      

+1


source







All Articles