LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2016, 03:13 AM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 72

Rep: Reputation: Disabled
Using ftp to transfer files from one server to another


I am using FTP to login into remote server to copy files

#!/bin/sh

DUMPS=/root/exp/
TMP=/root/tmp

find $DUMPS/*.sql.zip -type f -mtime +15 -exec cp {} $TMP \;

cd $TMP

# FTP Login

HOST=ipaddr
USER=usrname
PASS=passwrd123
REM_DIR=/home/bkpdir

for f in *; // the second time when i run the script
do
echo "Uploading file via FTP:" $f

ftp -in $HOST <<EOF

quote USER $USER
quote PASS $PASS

cd $REM_DIR
put $f
bye
EOF

done



It works fine but the problem i have to run this daily to copy files which are 15 days old in dumps dir.

There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?

Last edited by hruday; 01-06-2016 at 03:46 AM.
 
Old 01-06-2016, 03:41 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
duplicate of https://www.linuxquestions.org/quest...ct-4175562924/
 
Old 01-06-2016, 03:47 AM   #3
hruday
Member
 
Registered: Jun 2015
Posts: 72

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
hi pan64
as expect was not working for me I created script using ftp.
 
Old 01-06-2016, 11:13 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by hruday View Post
There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?
Use keys or expect with rsync. I posted a complete and working example of using expect for this purpose in your other thread, but I didn't see any response to that post indicating problems or questions. Did you even try it?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
transfer files created on last day of month to ftp server hruday Linux - Newbie 34 12-07-2015 08:17 AM
file transfer program in c using FTP client and FTP server renuaseri Linux - Newbie 2 01-29-2011 06:49 AM
ftp : need to transfer 2.5terrabyte(huge number of files), good ftp program ? ghoulsblade Linux - Software 8 10-29-2009 04:59 AM
Help needed to transfer list of files to FTP server, to different folders amazon Programming 1 06-26-2009 02:12 AM


All times are GMT -5. The time now is 10:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration