[SOLVED] Downloading file from FTP server to Unix box
AIXThis forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am writing one script for automation purpose in that i am downloading one file from FTP server[Windows] to unix box. I have written most of the code only part left is checking availability and downloading.
we get file once in a week at FTP Server some name like "ABCD-23220140303" at anytime on any day. so purpose is to pick the newly file arrived and ignores the previous week file so here previous week file will be like ""ABCD-23220140302" and the next week file will be "ABCD-23220140304".
Script will run daily and just check the file if newly file arrived will pick else will written log no new file available. written some piece of code.
Since you've written the script, why don't you post it here, so we can see what is going on? You tell us what you want to do, but don't tell us what you've tried/done, or show us what error(s) you're getting.
Well, it depends on what the numeric part signifies I guess, but you could do an ftp ls and compare 'new' list to 'current' list (both sorted of course).
If the new list is longer, fetch the new entry.
Assuming the number is some sort of serial or datetime, you can check to see if you've got it already.
Basically only you can specify the requirement, especially if the 2 lists are not necessarily the same length at any given time.
In fact, you just need to diff the lists, favouring the new list over the old ie what appears on the new and not in the old.
Could be stored in a flat file I think; once a week is only 52 files a year.
Append each new filename as you retrieve it.
Thnaks Chris you got my concern,I was expecting a some Piece of Code for listing the files and comparing with the the new one...
chrism01 posted a suggest that's easily implemented. Read the man page on the diff command.
Originally Posted by azheruddin
Appreciate if anyone has having other approach rather than listing and comparing...
Originally Posted by azheruddin
can anyone suggest on my request.
You were given a suggestion...coming back to bump your own thread after less than 24 hours is fairly rude. And, you were asked what input you were getting, but didn't post it. Unless you provide details, there's little else anyone can suggest. And why are you not using SFTP/SCP, which would make scripting MUCH easier?
If the ls output of the ftp server includes the timestamp you can list and shorten the list based on that criteria. I dealt with an NT service that grabbed things off of an ftp server a decade-ish ago. I modified it to make sure that the last written timestamp was > a minute old, as it tended to grab files before they had been fully uploaded. Hopefully the file in question is in a dedicated directory to limit the output of ls.