Operating System - HP-UX
1753418 Members
5146 Online
108793 Solutions
New Discussion юеВ

Re: Compress a file before ftp

 
MacMcDonald
Advisor

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 command contained 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 <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}
16 REPLIES 16
Coolmar
Esteemed Contributor

Re: Compress a file before ftp

MacMcDonald
Advisor

Re: Compress a file before ftp

thanks for the reply, my problem is that I have more than 80 servers to connect to in turn. I have edited the .netrc file to contain the user password details to enable autologin. This only seems to work with ftp, is there anyway I can include a telnet session in the script to compress the file in the same script prior to the ftp transfer?
Christian Tremblay
Trusted Contributor

Re: Compress a file before ftp

echo "connecting to $sd on $ip"
remsh gzip

add .gz extension to your ftp get in your script
MacMcDonald
Advisor

Re: Compress a file before ftp

for some reason when I add the line:

remsh gzip {filename}

it does not connect using that command, it seems to pass it by and run the get command direct, falling over because the .gz file is not there yet.
OldSchool
Honored Contributor

Re: Compress a file before ftp

appears to be a small typo in Christian's reply. try:

remsh $sd gzip

needs to know server to run command on
OldSchool
Honored Contributor

Re: Compress a file before ftp

or it might be $ip (if $sd isn't the dns name)
Christian Tremblay
Trusted Contributor

Re: Compress a file before ftp

not a typo, i avoid putting actual working commands because a lot of people rely on this forum to do their job for them.

I put just enough for a knowledgable user to figure it out.
MacMcDonald
Advisor

Re: Compress a file before ftp

again thanks for the reply guys - i already tried both the $sd and $ip before asking, it seems that the redhat box I am running the script from doesn't understand the remsh command.....
Christian Tremblay
Trusted Contributor

Re: Compress a file before ftp

You can substitute ssh to remsh ( which is a lot better and secure ) but you would have to deploy you ssh keys to all your servers to enable passwordless remote execution.
Which is a good thing to do if you have not already done so.

man ssh

Chris