Compress a file before ftp

Hi,

I have a script that ftp's to over 100 deifferent servers in turn, gets a specific file, renames it and drops it onto a local backup server. The files vary in size from 4mb to 150mb. I am within a secure intranet to security with ftp is not an issue. I want to auto compress the file before I ftp it over the network, either as a seperate script or as a comand conatained within my original.

Can anyone help?

the current script is as follows:

hostFile=/data01/global_backup/scripts/GLOBAL_hostFile.txt
while read ip sd
do
echo "connecting to $sd on $ip"
ftp -dv $ip <<EOF
get /global/prd/cycle/export/full_export.dmp /data01/global_backup/files/monday/$sd.full_export.dmp
bye
EOF
if [ $? -ne 0 ]; then
echo "Had a problem connecting to $sd on $ip"
else
echo "Connected to $sd on $ip"
fi
done < ${hostFile}

If your system supports remsh, try something like this

hostFile=/data01/global_backup/scripts/GLOBAL_hostFile.txt
while read ip sd
do
  echo "connecting to $sd on $ip"
remsh "$sd" compress /global/prd/cycle/export/full_export.dmp 
if [[ $? -ne 0 ]] ; then
   echo "error compressing file on $sd"
fi 
ftp -dv $ip <<EOF
bin
get /global/prd/cycle/export/full_export.dmp /data01/global_backup/files/monday/$sd.full_export.dmp
bye
EOF
if [ $? -ne 0 ]; then
echo "Had a problem connecting to $sd on $ip"
else
echo "Connected to $sd on $ip"
fi
done < ${hostFile}