Script to recursively look for a file on ftp server until it found

Tag: unix Author: houych Date: 2009-08-09

I just want to transfer a file from ftp server to unix folder, --this is stright forward. if the file doesn't exist on the ftp server, then the script needs to run recursively until it finds the file. Please let me know how do i get that file.

please remember script has to run on ftp server.



I can recommand ncftpget, ncftpput, ncftpls. Ideal for scripting FTP commands.

Other Answer1

I'd mount the FTP server with curlftpfs and then use it like it were a local file system — for example, run find(1).

Other Answer2

You need to write a program to automate your FTP session. You can either write your own custom FTP client, not that hard if you know a few things about network programming, or write a script to automate a session for an existing client. For the latter approach, I suggest using Expect if you are proficient with TCL, or PyExpect if you prefer Python. Expect is a library designed to automate interactive tasks like downloading a file with FTP.