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?
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!