“I agree that batch processing(mget) is better way of transferring…”
The definition of “better” depends on what you’re trying to do. If the storing of files in the local file system is not desired, then mget is not better, it’s worse.
Effeciency-wise, there is not all that much difference between doing an mget or an ls and looping to do multiple gets.
“where I have to close FTP session for each file and open another FTP session for sending each file.”
Why do you have to do this? Would this approach work:
- login to FTP server A
- login to FTP server B
- cd on server A if needed
- cd on server B if needed
- ls from server A
- loop over dirlist
**** get file from server A
**** put file to server B - logout from server B
- logout from server A
A key part of this working is to manage the pipeline appropriately so that the FTP sessions don’t get mixed up. This is probably most easily done using scope on each service call.
With this you’ll have 1 session to each server and effectively be acting as a file transfer bridge. (Even more efficient would be to have a script on FTP server A simply push files directly to server B–would that work?)