tags:

views:

1448

answers:

2

I am creating a script on the fly to ftp some files from a remote computer. I create 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

That doesn't work. Neither does the following:

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

Obviously, I'm not so good at ftp. How, in what order, where in my file do I specify the place where I want the files to be put (destination directory, and also from where the ftp process is running), and where I want the files to come from (ip address computer which has files I want). Do I need to set the directory before starting the ftp process?

I'm running this in an SSIS package, and I'm not using the SSIS ftp task, because I don't want a failure if no files are found. If there's nothing there, that's cool. If there is something there, I want a copy.

(It was working in my development area, and now, when I'm trying to get files from a server that I truely have no access to except ftp, I'm not getting anything. See http://stackoverflow.com/questions/140850/the-best-way-for-a-ssis-ftp-task-to-not-fail-when-there-are-no-files-to-copy for an earlier, related question.)

Update: Both of the answers below, listing lcd and cd, are correct. However, my example still failed, until I replaced the backslashes with forward slashes. In other words, my final, working result is as follows:

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

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

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 that with ftp. If you wished to copy files from one folder on the ftp server to another, then I believe you would get a copy to the local system, and then reupload them to a new folder. If you wish to move files you can use the rename command.

Zoredache
No, I am trying to copy files from computer A to computer B, running the script from computer B.
thursdaysgeek
A: 

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

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