Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic - FTP

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi

Can any one help me in giving the script...

I have A & C directories in one machine and B &D directories in remote machine.

I want this script to contact the remote machine and upload all the files from A to B and download all the files from D to C.

THanks in advance
 
Assuming you have your two machines locally networked together
and you have permissions to use "rcp" you can
do...

rcp -pr remote_user@remote_host:A/* ./B
rcp -pr ./D/* remote_user@remote_host:C

Check the man pages for rcp and rhosts for specific setup info.
You can easilt incorporate this command into a shell script.

If you are not locally networked and must go through a "public"
network then I would suggest looking at "scp". This setup
would be more involved and require SSH protocols be installed
and running on both ends. Then you should set up your authentication
keys, etc.
 
For the quick ("and dirty") way you could use something like:

#!/bin/sh
# ----------------------------------------
# FTP script
#
# By: Laurie Baker
#
# This is where you specify the settings for the ftp
# Changes will be: host,user, password & dir's
# ----------------------------------------
host=192.168.211.62
user=ftpuser
password=yourpassword
destination=/home/dir/B
errorlog=/some/dir/for/ftperror.txt
#------------------------------------
echo "-----------------------------" >> $errorlog
echo `date` >> $errorlog
echo "-----------------------------" >> $errorlog
ftp -v -n $host << EOF >> $errorlog
user $user $password
prompt
ascii
cd $destination
lcd /home/where/to/get/files
mput *
quit
EOF
print &quot;Proces complete&quot;

Ok so you can play with it and get fancy by adding the second requirment with a &quot;mget&quot;

Good Luck.
 
HI Tarn

Thx for your help. I did the required changes and it worked well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top