Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 May 2001 17:45:36 -0400
From:      Damien Tougas <damien@carroll.com>
To:        Tony Wells <awells@journalstar.com>
Cc:        Daniel Frazier <dfrazier@magpage.com>, freebsd-questions@FreeBSD.ORG
Subject:   Re: Scripting FTP actions
Message-ID:  <199050000.989963136@01.dhcp.hck.carroll.com>
In-Reply-To: <3B019740.2110063D@magpage.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--On Tuesday, May 15, 2001 16:53:20 -0400 Daniel Frazier 
<dfrazier@magpage.com> wrote:

> Tony Wells wrote:
>>
>> Hi all,
>> I need to be able to set up something where I can script a bunch of
>> FTP actions to send files to a remote server and I'm not sure where to
>> start looking.
>>
>> As far as a client I use ncftp, and looking at the man page I only see
>> "auto fetching" of files.
>>
>> Has anyone done this, or am I better off just writing a perl script
>> that pretends to be an FTP client?
>>
>
> I'd use scp.  with scp you can utilize a ~/.ssh/authorized_keys file
> on the destination machine and you won't have to put any passwords in
> the script.

Another way you can do this is by setting up macros for the FTP client. I 
am not very familiar with ncftp, but I do know you can do this with the 
FreeBSD ftp client. If you put a macro in your .netrc file called init for 
a particular host, it will be automatically processed as soon as you try to 
connect to a that host. An example .netrc file is as follows:

    machine ftp.someplace.com
    login dude
    password abc123
    macdef init
    passive
    lcd /home/dude/textfiles
    cd /upload/dude
    mput *.txt
    quit

When I type "ftp ftp.someplace.com" at the command line or put it in a 
script, the init macro will automatically be processed, uploading all *.txt 
files from the /home/dude/textfiles directory to /upload/dude on the remote 
server, then logoff.

Check out the ftp man page for more details.

---
Damien Tougas
Systems Administrator
Carroll-Net, Inc.
http://www.carroll.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199050000.989963136>