Re: ftp problem on bash script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/12/10 13:52, a bv wrote:
> Hi Im trying to write a bash script which will run on Checkpoint
> Secureplatform (which is
> Redhat indeed) seems below. First part of the script will make an
> yesterdays log archive ,
> other part will  copy this archive to an ftp server. The archive
> creation process works fine when ftp part is commented or deleted, but
> doesnt work. As one script or another script for ftp, how can i work
> this to create the archive and and copy it to the ftp site.
> 
> Regards
> 
> 
> # !/bin/sh
> 
> # Define string variables!
> hostname="intsrvb.abank.com.tr"
> ftp_server="myserver"
> ftp_username="myuser"
> ftp_password="mypassword"
> cpdir=/opt/CPshrd-R70
> localbakdir=/opt/CPsuite-R70/fw1/log/
> remotebakdir=/tape/2010tape/log/omega/cp/
> logdate=`/bin/date --date="yesterday" +%Y-%m-%d`
> logname=${logdate}
> archivedate=`/bin/date --date="yesterday" +%Y_%m_%d`
> archivename=logs_${hostname}_${archivedate}
> 
> # Set Check Point profile for library settings!
> . $cpdir/tmp/.CPprofile.sh
> 
> 
> # Archive yesterday`s log files!
> cd ${localbakdir}
> /bin/tar zcf ${localbakdir}${archivename}.tgz ${logname}*
> 
> # FTP files to backup server!
> #ftp -in $ftp_server <<EOC
> #user  myuser mypassword
> #binary
> #cd ${remotebakdir}
> #lcd ${localbakdir}
> #put ${archivename}.tgz
> #bye
> 

FTP won't read passwords from a redirected input script.

You need to create .netrc file, or maybe expect will work but it's so
long since I worked with automated FTP that I can't remember.

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@xxxxxxxxxxxx
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list


[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux