- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- download scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 03:09 AM
11-25-2003 03:09 AM
I'm wishing to write a script that will :
1. open an ftp server myserver.com
2. Move to a defined directory /somedir
3. Check if files there are different or more recents than the files I already downloaded in localhost/mydirectory from this server.
4. Download the new or more recent files, ignoring files older than, say 120 days.
5. Check in localhost/mydirectory if files here came to the 120 days dead end (files downloaded before, of course).
6. Delete these old files.
Any proposition ?
5 points for any new part,
2 points for an addition or improvement,
and of course a rabbit for the full script.
Thanks.
J
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 06:41 AM
11-25-2003 06:41 AM
Re: download scripting
I've played with something like this before. I'd suggest writing the script in Perl and using the Net::FTP module. It will handle all your FTP connection and file commands and it will make life much easier.
Take a look at it here:
http://search.cpan.org/~gbarr/libnet-1.17/Net/FTP.pm
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 05:35 PM
11-25-2003 05:35 PM
Re: download scripting
Failing that, ncftpget server:/path/, and a find would do most of that for you ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 06:41 PM
11-25-2003 06:41 PM
Re: download scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 07:00 PM
11-25-2003 07:00 PM
SolutionThat script clears out tmp files over seven days old. There is some interactive junk to clear out but it works great in batch mode, change the target directory for the find and the number days to deal with your 120 day requirement
I would suggest running this script and modifying it to move eligible files to a staging directory instead of the rm command it currently uses.
Here is the ftp part:
ftp -v -n <
user username password
cd /somedir
lcd localhost/mydirectory
put filename
EOF
A while loop can be but around the ftp command running it multiple times based on the list producted in the first script.
The Script at the top can have a second copy run to delete the 120 day old targets. The government might not let you clone humans, but this script likes being cloned. That covers 5 and 6.
I just drove to STL from Chicago and my daughter won't sleep. Given a couple of hours, I can produce you a working, tested script. In case you are in a hurry however, my pieces will work.
I would suggest the possiblity of using openssh to skip the ftp part and make the file transfer somewhat secure.
Let me know if you want a finished product. When I deliver depends on factors beyond my control at this time.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 10:49 PM
11-25-2003 10:49 PM
Re: download scripting
I have been job hunting (former company now for sale), forgot how much time this exercice required, it as keep me busy theses last few day's !, Jerome this is a good exercice for RHCE exams I will have a go at it this evening if someone else did not beat me to it .. specialy SEP ...
but question ? you want only ftp and bash ? could we use sftp or rsync ?
J-P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 02:25 AM
11-26-2003 02:25 AM
Re: download scripting
will do the trick except:
- it does not ignore files on the FTP server older than 120 days
- it does not delete local files older than 120 days
tmpwatch is the easy way to delete old files
- add in cron.daily (or monthly)
/usr/sbin/tmpwatch 240 /dir/to/prune
I don't think you can retrieve files based on date without writing a FTP application.
If you really need to get based on date I think your best bet would be to use the ncftpspooler, ncftpbatch, ncftpget suite.
Cheers
Cristi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 02:25 AM
11-26-2003 02:25 AM
Re: download scripting
the deletion is pretty straight forward, run something like
find /path -mtime +120 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 03:13 AM
11-26-2003 03:13 AM
Re: download scripting
http://www.hpux.ws/Cleantmp
Is up so try that one.
I'm solo on Parent patrol so it will be a while before I can try that script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2003 08:42 AM
11-27-2003 08:42 AM
Re: download scripting
Benn traveling to attend Computer security fair in Paris. Fun to see that many vendors know their product so well and security so bad ! Is it the same in USA ?
Back to the point. Thanks everyone for working on my prob.
John, thanks for the idea. But I must confess I'm a perl dummy. I know how to use a program, but am very weak at wrtting any change on it... unless it's done for me :]] But why not, with a few help...
Stuart, I've heard about mirror program, but can't find it back : do you have any pointer ?
Vitaly, thanks for rsync idea, but the trouble is that I do not want to re-download the full directory, as I'm throwing away old programs, which the original directory doesn't...
Steven, Thanks for the link, I got it from hpux.ws. I'll try it tommorrow (late here...) and tell you who it turns to bash (it's ksh, but doesn't seem to be too sepcific :] )
Christian, yes, that's the issue, not redownloading what I will delete anyway...
Patrick, you may have it ! Looking at the scripts you suggest seems to be a workable solution : once again, 'll try it tommorrow !
Jean Pierre, as an RHCE, why not suggest something on rsync and find, even incomplete ?
I'll assign points too tommorrow : any last suggestion ?
Thanks a lot anyway !
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2003 10:16 AM
11-27-2003 10:16 AM
Re: download scripting
ftp://ftp.cs.columbia.edu/archives/perl/mirror/
It has the ability to delete files older than 'max_days' of age.
I'm not sure if it will also delete local files (I think it will).
It's old, circa 2000, but it was a fantastic tool then, and is a good one for the war-chest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2003 07:59 PM
11-27-2003 07:59 PM
Re: download scripting
What I had in mind is something like the following
I first would delete old from remote structure as your question made me think you had delete rights on remote directory !
then rsync remote to local
then clean old on local
Something like this
ssh JeromeHenry@myserver.com 'find /somedir -mtime +120 -exec rm {} \;'
rsync -avz -e ssh myserver.com/somedir /mydirectory
find /mydirectory -mtime +120 -exec rm {} \;
a very busy, but having some positive replies
J-P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 02:41 AM
11-28-2003 02:41 AM
Re: download scripting
rsync -avz -e ssh myserver.com/somedir /mydirectory
with
rsync -avz -e ssh JeromeHenry@myserver.com:/somedir /mydirectory
forgot the ":"
I ssh is setup right pn source and target it does not ask for password.
J-P (0 pts for this mea-culpa and add on)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 04:44 AM
11-28-2003 04:44 AM
Re: download scripting
just source the file within another script and the functions will be available in your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 04:56 AM
11-28-2003 04:56 AM
Re: download scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 07:13 PM
11-28-2003 07:13 PM
Re: download scripting
Steven and Stuart's tips are 2 100% workable solution, ready to use.
Jean Pierre's is also workable, except that I do not have write rights on remote server... so should it have to be turned slightly differently to take this into consideration.
Thanks again for all this work ! I consider this thread as solved.
I'll have another question in 10/12 days :]]
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 11:29 PM
11-28-2003 11:29 PM
Re: download scripting
Slight modification in find script :
find /path -ctime +120 -exec rm -f {} \;
I prefer -ctime to search for creation date instead of modification, then use -f not to be asked at each line if I'm sure to remove this file, and space is required between {} and ;
Thanks again !
J