#! /bin/bash
#
# usage: getalllogs [reg expression name for directories in logs]
#    eg: getalllogs 2001.290.*
#
# WARNING!!! Do not run this from a directory where the shell can expand the
#            argument into a directory name. Execute this from //c if you
#            need to.
#

# Purpose: automagically logs into potato (QNX laptop), copies over
#          all log files in the directories specified in the argument
#          to a local directory on potato, converts all binary log files, then
#          transfers all of the files to the f: drive on willet.

cd //f/healy_data/auv/logs

rsh -l dorado1 potato "(source ~/.profile; cd logs; cp -v -R -A -M unix //1/home/dorado1/auv/altex/onboard/logs/$1 .; cd ..; find logs -type d -name "$1" -print -exec cvtdir {} \;; cd logs; tar -cvf xfer.tar $1;)"

ncftpget -u dorado1 -p dorado1 potato . /home/dorado1/logs/xfer.tar
rsh -l dorado1 potato "(cd logs; rm xfer.tar; rm -rf $1;)"
tar -xvf xfer.tar
rm xfer.tar
find . -name "*.gz" -print -exec rm {} \;

echo
echo All Done
