[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: Commandline FTP



Darren Benham <gecko@benham.net> writes:
>
>Does anyone know of a program/script that will SEND files to an FTP site?  I
>know that 'ftp' can be used to RETRIEVE.  I want to upload files via a makefile.
>

    You can use FTP to "PUT" just as well as you can to "GET".  Heres a script
    that I wrote a while ago to upload files via a script. (This was written
    to work on a sun system, but I know it's been used on others).

                                                -Jeff

--------------------------------------------------------------------------------
#!/bin/csh -f
#!
#! Trans:  Written by Spectre@albert.bu.edu
#!
#! Usage: trans [remote-directory] file
#!
#! Designed to easily transfer files via ftp with a one line command.
#! To use, simply save this file to a file named 'trans' in a directory
#! that is in your path.  use 'chmod 700 trans'  to modify the protections
#! for use as a file.
#!
#! This script is owned in whole by Jeff Schreiber (spectre@albert.bu.edu),
#! and permission is granted for copy and modification providing that this
#! paragraph is provided and unchanged.
#!
#! Should be used in conjunction with ~/.netrc, where .netrc has an entry:
#!      machine <ftp site>
#!              login <account name>
#!              password <password>
#!      The password is optional, and will be prompted for at runtime if
#!      Not present.
#!
#! NOTE:
#!      For if you plan to use ~ expansion on the directory name, for
#!      example 'trans ~spectre workroom.c', you must 'de-reference' the
#!      ~spectre so it will get to the shell script.  Instead of using
#!      ~spectre, use "\~spectre".
#!
#! Examples:
#!      % trans toys bokken.c
#!        Putting file 'bokken.c' in directory 'toys/'
#!        Password:
#!        Done.
#!      % trans "\~balack" workroom.c
#!        Putting file 'workroom.c' in directory '~balack/'
#!        Done.

set system = "albert.bu.edu"
set port = 3500

if ($1 == "") then
        echo "Usage: trans [remote-directory] file"
        exit
endif

set directory = "."
set file = $1
if ($2 != "") then
        set directory = """$1"""
        set file = $2
endif

echo "Putting file '"$file"' in '""""$directory""""'"
ftp -i -v $system $port <<xxxPUTFILExxx
    cd $directory
    mput $file
    quit
xxxPUTFILExxx

echo "Done."
exit
--------------------------------------------------------------------------------

     *****************************************************************
     |    Jeff Schreiber     | I do not like C chmod and fgetname.   |
     |    aka - "Spectre"    | I do not like them, VAXman I am!      |
     | schreiber@process.com |     (VAXman@tmesis.com)               |
     *****************************************************************


Reply to: