Current location: Hot Scripts Forums » General Community » Script Requests » Bash script to copy file from one ftp to other ftp

Bash script to copy file from one ftp to other ftp

Reply
  #1 (permalink)  
Old
New Member
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Bash script to copy file from one ftp to other ftp

HI
i need a bash script to copy file(s) from one ftp to other ftp and can any one plz help
Thanks in Advance
Reply With Quote
  #2 (permalink)  
Old
End User's Avatar
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by uravikishore View Post
HI
i need a bash script to copy file(s) from one ftp to other ftp and can any one plz help
A quick and dirty example on how to automate ftp in a bash script:

Code:
#!/bin/bash

/bin/ftp -inv ip_address_of_target<<ENDFTP
user username user_password
cd folder_on_target_station
bin
lcd folder_on_local_box
put filename.txt
bye
ENDFTP

You should replace all of the filenames, addresses and paths for your particular server.


This is a more verbose example I found, study it to understand what's going on....

Code:
#!/bin/bash
 
### getFTP v.1 #################
#
# Variables : use backquotes!#
DATE=`date +%Y%m%d`
HOME='/home/itdev/scripts/mepco'
#
HOST='remotehost'
USER='myUser'
PASSWD='myPasswd'
FILE='*.txt'
#
####################################
 
# Make directory of current date, make that directory local
mkdir $HOME/$DATE
cd $HOME/$DATE
 
# Login, run get files
ftp -inv $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
mget $FILE
!ls > $DATE.list
bye
END_SCRIPT

for file in `cat $DATE.list`
do
ftp -inv $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
rm $file
bye
END_SCRIPT
done

# Cleanup
exit 0

NOTE: This will use multiple ftp connections which might be rather expensive in terms of load on the system.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | Call Of Duty
Reply With Quote
  #3 (permalink)  
Old
New Member
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the post

how to write the script for mirror the ftp. menace if any thing is uploaded a file or folder in "A" ftp directory it also has to copy in the another "B" ftp

Thanks in advance
Reply With Quote
  #4 (permalink)  
Old
New Member
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
FTP prog from Windows to Linux/Solaris

HI,
I want to write a program which can perform the FTP from Windows to Linux/Solaris machine.Can any one help me in this task?thanks in advance.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit button....can it send info to my email w/out the use of php???? lisa33 HTML/XHTML/XML 7 10-17-06 12:46 PM
Programmer Needed for File hosting script! Fabolous Job Offers & Assistance 3 06-15-06 11:56 PM
Script for splitting a file into several files saleem Perl 4 06-27-05 09:55 PM


All times are GMT -5. The time now is 09:13 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.