Languages and Scripting

FTP Script to transfer archive log files between 2 HP-UX servers.

 
SOLVED
Go to solution
Narendra Uttekar
Regular Advisor

FTP Script to transfer archive log files between 2 HP-UX servers.

Hi,
I need to transfer archive log files between 2 HP-UX servers. Every 10 min the FTP schedule script will run. So that if file is available
script will ftp the file. And also script should have logic of sending the latest archive log files of last FTP script run, So that the script will send only the latest files when script again run at schedule time.

And also before the script run it should check whether this ftp script is already running, If script is already running then it should not run the FTP script again.

Please let me know how to modfiy the FTP script below to have the above requirement.

#!/bin/ksh
cd /directory/Outbound
HOST='ftp.test.com'
USER='unix'
PASSWD='unix'
ftp -n -v $HOST << EOF
user $USER $PASSWD
lcd /directory/Outbound
cd upload
bin
prompt
mput *.LOG
EOF

Thanks,
Narendra
6 REPLIES 6
Jose Mosquera
Honored Contributor
Solution

Re: FTP Script to transfer archive log files between 2 HP-UX servers.



#!/bin/ksh
if [ -f /tmp/.ftpbusy ]
then
echo "Busy by a previuos ftp proccess"
else
touch /tmp/ftpbusy
cd /directory/Outbound
HOST='ftp.test.com'
USER='unix'
PASSWD='unix'
ftp -n -v $HOST << EOF
user $USER $PASSWD
lcd /directory/Outbound
cd upload
bin
prompt
mput *.LOG
EOF
rm /tmp/.ftpbusy
fi
Jose Mosquera
Honored Contributor

Re: FTP Script to transfer archive log files between 2 HP-UX servers.

Hi,

Previous post aviods overlapping of processes using a file control (/tmp/.ftpbusy). Use a convenient place to create it.

To controls lastest log files you could rename them to a sent extention (i.e: .LOG.SENT), once the mput command have been done. Or move them to a sent log directory once sent them (mv *.LOG /anywhere). By this way you just have the last files to send when you execute mput *.LOG.

Rgds.
Narendra Uttekar
Regular Advisor

Re: FTP Script to transfer archive log files between 2 HP-UX servers.

Hi,
As log files are generated incremental by one i.e. LOG.001,LOG.002,LOG.003. Can we have a logic to check which log files are transfer base on log sequence number so that next time it will send only the logs which were not earlier sent.

Thanks,
Narendra
James R. Ferguson
Acclaimed Contributor

Re: FTP Script to transfer archive log files between 2 HP-UX servers.

Hi:

Given that your logfiles are named in the format "LOG.001, LOG.002, LOG.003", etc. to find the next name to use, you could do something like:

# cat ./nextlog
#!/bin/sh
LAST=$(ls -r LOG.*|head -1|sed -e 's/LOG.//')
[ ${LAST} = 999 ] && LAST=0
LAST=$(( LAST+1 ))
NEXT=$(printf "LOG.%03d\n" ${LAST})
echo ${NEXT}

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: FTP Script to transfer archive log files between 2 HP-UX servers.

Shalom,

A lower band width alternative might be to use rsync to copy files between servers. rsync, available from Internet Express on http://software.hp.com has options to only copy over files that have changed, and not bother recopying the entire set of files.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
DK_SYB
Visitor

Re: FTP Script to transfer transaction log backup files between 2 HP-UX servers from DC to DR server

Can anybody let me know the shell script to transfer sybase ase transaction log backup files between 2 HP-UX servers i.e. Primary site to DR site?

I need full script to schedule it from Primary server which will transfer these files to DR.

 

Later , i need to schedule it using crontab.

 

 

Regards,

DK


@Jose Mosquera wrote:


#!/bin/ksh
if [ -f /tmp/.ftpbusy ]
then
echo "Busy by a previuos ftp proccess"
else
touch /tmp/ftpbusy
cd /directory/Outbound
HOST='ftp.test.com'
USER='unix'
PASSWD='unix'
ftp -n -v $HOST << EOF
user $USER $PASSWD
lcd /directory/Outbound
cd upload
bin
prompt
mput *.LOG
EOF
rm /tmp/.ftpbusy
fi

@Jose Mosquera wrote:


#!/bin/ksh
if [ -f /tmp/.ftpbusy ]
then
echo "Busy by a previuos ftp proccess"
else
touch /tmp/ftpbusy
cd /directory/Outbound
HOST='ftp.test.com'
USER='unix'
PASSWD='unix'
ftp -n -v $HOST << EOF
user $USER $PASSWD
lcd /directory/Outbound
cd upload
bin
prompt
mput *.LOG
EOF
rm /tmp/.ftpbusy
fi

@Jose Mosquera wrote:


#!/bin/ksh
if [ -f /tmp/.ftpbusy ]
then
echo "Busy by a previuos ftp proccess"
else
touch /tmp/ftpbusy
cd /directory/Outbound
HOST='ftp.test.com'
USER='unix'
PASSWD='unix'
ftp -n -v $HOST << EOF
user $USER $PASSWD
lcd /directory/Outbound
cd upload
bin
prompt
mput *.LOG
EOF
rm /tmp/.ftpbusy
fi