How to keep track of filename in different shell

Guys I am trying to install the pkg using the follwoing script.
Trying to run the script from one machine to other machines with the follwoing code.

Now my problem is, when I use scp command on the remote machine, how do i keep track of filename in some variable or that sort of thing.

Below is the sample code.

for GETHOST in `cat $FILENAME`
do
echo "\n Logging onto $GETHOST"
ssh $GETHOST <<EOT
#Getting the machine info for Sparc / AMD machine
TYPE=`uname -a | awk '{print $6}'`
if [ $TYPE != sparc ];
then
scp beast:$AMD_DIR/.pkg.tar.gz $GETHOST:/home/somename/pkg/
if [ $? = 0 ];
then
echo " Copied the file(s) Successfully on $GETHOST from beast"
else
echo " File(s) not copied on $GETHOST from beast"
exit 2
fi
[Here I have to keep track of all the recent files that have been scp'ed]or suggest any other alternative or any other condition please]
else
scp beast:SPARC_DIR/
.pkg.tar.gz $GETHOST:/home/somenam/pkg/
if [ $? = 0 ];
then
echo " Copied the file(s) Successfully on $GETHOST from beast"
else
echo " File(s) not copied on $GETHOST from beast"
exit 2
[SAME LIKE ABOVE - Here I have to keep track of all the recent files that have been scp'ed]or suggest any other alternative or any other condition please]
fi
fi
# Better to check once again if scp is successfull
# End of here document
EOT
# End of main for loop
done

Don't know how tab spaces converted into plain text.
please tab by yourself on the If conditions for more clarity....

filelist="$filelist
NEXTFILE"

Please put code inside

 tags.

for GETHOST in `cat $FILENAME`

[/quote]

[indent]
While it probably doesn't matter in this case, that is almost always the wrong way to read a file. Use a while loop:

while read GETHOST
do
   TYPE=$(ssh "$GETHOST" uname -m)
   case $TYPE in
      sparc) sourcedir=SPARC_DIR ;;
      *) sourcedir=$AMD_DIR ;;
   esac
   scp beast:"$sourcedir"/*.pkg.tar.gz "$GETHOST":/home/somename/pkg/ > LOGFILE &&
    echo " Copied the file(s) Successfully on $GETHOST from beast" || {
    echo " File(s) not copied on $GETHOST from beast"
    exit 2
   }
done < "$FILENAME"

thanks dude...code looks good...but my issue is.... after scp i want to run the pkginstall commands with each filename i scp'ed ... since i am in different shell. isn't it difficult to track the filename of AMD / SPARC directories???? so any alternative to get the file name scp'ed and then use it for pkginstall command...

You have the names in LOGFILE.

Thanks john.... it was skipped from my eyes....yeah we can take from LOGFILE.....
Cheers and thanks for the help. will come again on this forum if stuck with some issue.