#!/bin/bash 
#
# PURPOSE:  copy log files to ~/logs/$1 in QNX 4.5.
# AUTHOR:   Rob McEwen
# DATE:     2008/12/3
#
cd "$HOME/logs"
pwd
if [ $# -eq 0 ]
    then
    echo " "
    echo " Enter directory name."
fi
if [ $# -eq 1 ]
    then
    if [ -a "$1" ] 
	then
	echo " "
	echo " $1 already exists!"
	cd $1
    else
	mkdir $1
	cd $1
    fi
    echo "Logging into $AUV_HOST"
    rsh -l $USER $AUV_HOST "(./cplogs $1;)"
    ncftpget -u dorado1 -p dorado1 $AUV_HOST  . /home/rob/logs/$1/*.gz
    gunzip *.gz
elif [ $# -eq 2 ]
    then
    if [ -a "$1" ] 
	then
	echo " "
	echo " $1 already exists!"
	cd $1
    else
	mkdir $1
	cd $1
    fi
    if [ $2 = "all" ]
	then
	echo "Logging into $AUV_HOST"
	rsh -l $USER $AUV_HOST "(./cplogsall $1;)"
	ncftpget -u dorado1 -p dorado1 $AUV_HOST  . /home/rob/logs/$1/*.gz
	gunzip *.gz
    fi
    if [ $2 = "tar" ]
	then
	echo "Logging into $AUV_HOST"
	rsh -l $USER $AUV_HOST "(./cpbigtar $1;)"
	ncftpget -u dorado1 -p dorado1 $AUV_HOST  . /home/rob/logs/$1.tgz
	tar -xvzf $1.tgz
	rm $1.tgz
    fi
fi
cd ..
echo " "
echo "getlog $1 finished."



