Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, iphone help, ipod help, AdSense, MySpace, Sony PSP help, Mp3 players, Windows XP, Windows Vista, Linux, SEO, Mac OS X, Facebook, Twitter and LinkedIn.

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?

Dave's Answer: I don't have a hybrid script, but the core piece you're talking about is this:
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
fi
If 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    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments
Rather amazingly, there are no comments on this article yet.


I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Member of the B5Media Network

Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]