|
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!
Categorized:
Shell Script Programming
(Article 3737,
Written by Dave Taylor)
Tagged: Previous: Interesting new Google Adsense Capabilities Next: Optimal placement of ads on your Web pages Subscribe!
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |