1752579 Members
4235 Online
108788 Solutions
New Discussion юеВ

Re: Simple FTP script

 
Victor Mendham
Regular Advisor

Simple FTP script

Anyone have a simple FTP script to automate the transfer of a file to multple systems? Anyone know how to encorporate chmod into this? I'm new to unix and thus scripting so
I'm wondering if anyone has a simple ftp script to do this or can walk me through it.
I want to ftp (+ prompt for user,passwd,but leave dir and file name as /etc/hosts) a standard host file to a bunch of systems and ensure permissions on it so it will be available for use. Running ITO and adding managed nodes across the wan and need to ensure host is the same in all locations.
4 REPLIES 4
Rick Garland
Honored Contributor

Re: Simple FTP script

LOG=
cd /

ftp -n -v > $LOG << ENDFTP
user
lcd /
get/put
ENDFTP

This will do just one host. Can embellish to do more.

Do a search for FTP in the forums and you will find multiple threads on this subject.
Antoanetta Naghiu
Esteemed Contributor

Re: Simple FTP script

Do a querry in the forum. You'll get more than one script.
Tim Malnati
Honored Contributor

Re: Simple FTP script

I suggest you look into the rdist utility. This process will copy files and/or directories to any number of designated machines. Additionally, by default it will maintain the permissions, ownership (if the user exists on the target box), and the file modification date of the files and structures as well. It has a variety of other capabilities as well (remsh, mailing, and others). At first the documentation can be a bit overwhelming, but learning how to play with this utility will be well worth your while down the street. The maps that you can devise can be as simple or as complex as you want. I've even performed a full database environment migration from an AIX box to an HP with a variety of file conversions in between by using rdist (100,000+ files). During the Y2K thing, it made creating and maintaining multiple environments a breeze. The nice thing is that you can map out areas you don't want to copy as well and files that have not changed will remain as is but will be verified.

There are two different versions of the utility. The HP version comes standard with the system but needs the fileset loaded from the install disks (it's not loaded by default on a new install). There are some patches out there too. The other version is available from GNU. I prefer this version where it has some additional capabilities and can also talk to non HP machines. The last I knew, the porting center has some binaries precompiled, but compiling it with either the HP ANSI C compiler or gcc is no problem.
Shannon Petry
Honored Contributor

Re: Simple FTP script

If you are going to do what I think, you may get yourself into some trouble. It is not advisable to copy an "/etc/hosts" file from one system to another. There is pertinant information in this file, which can upset your system if the order of information is disturbed.
I.E. If running bind, the name server should be the first entry, second entry is the local host, third entry is the loopback. Sendmail can have difficulty if this order is not preserved, as well as some other applications.
If you need to sync hostnames, can you run either bind, or nis? This would be the preferred method.
Regards
Shannon Petry
Microsoft. When do you want a virus today?