
Tweaking FTP scripts to fine-tune their behavior
A reader writes:
I have your Wicked Cool book and love it. I am new at scripting and it is helping a ton. Question. I need a script to use the timestamp feature (ingenious by the way) of Script #83 but "get" the files from a remote server like Script #82. Do you have one modified in such a way? if [ ! -f $timestamp ] ; then
# no timestamp file, upload all files
for filename in *
do
if [ -f "$filename" ] ; then
echo "put -P \"$filename\"" >> $tempfile
count=$(( $count + 1 ))
fi
done
else
for filename in $(find . -newer $timestamp -type f -print)
do
echo "put -P \"$filename\"" >> $tempfile
count=$(( $count + 1 ))
done
fiIf you're talking about script #82, then I surmise that you want to get the files rather than put them. So what happens if you just change the "put" to a "get" here? Well, there are two challenges. First off, your timestamp file might well now exist on the remote system (solved by doing an ftp 'get' before you proceed) and second, the list of files you want to grab aren't local anymore either. The latter is solved by generating a file listing (use "dir" in the ftp sequence), saving it, parsing it out (don't forget to include the last modified date/time), and then comparing each to the date/time of the timestamp file.
I admit, it's going to be quite a bit more work if you want to be really flexible in this solution, but given the speed of modern connections, it might just be easier to bulk "get" everything on the remote system regardless of the timestamp anyway. However you solve it, good luck!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
Shell Script Programming
(Article 3737)
Tagged: Previous: Interesting new Google Adsense Capabilities Next: Optimal placement of ads on your Web pages Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.
Rather amazingly, there are no comments on this article yet.
I have a lot to say, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|