[HPADM] RE: FTP Script

From: Beerse, Corné (c.beerse@torex-hiscom.nl)
Date: Thu Mar 13 2003 - 04:11:42 EST


> -----Original Message-----
> From: Roger Realsen [mailto:roger.realsen@wareforce.com]
>
> I currently use the following script to ftp files:
>
> ================================
> #!/bin/sh
> #
> # ftpsend.sh - transmit a file via ftp
>
> {
> # build the ftp command script
>
> echo "verbose" # for debugging and logging purposes
> echo "open $1" # open the connection to remote site
> echo "user" $2 $3 # supply the userid and password

There is a constant battle going on between the script-writing world to be
able to input a password in a stdio stream and the security world to force
the user to type passwords, not to put them in files.

Hence, many atempts to put a password in a stdio stream can succeed at one
stage, after a security update, the same construct can fail.

To be able to transfer files, there are many other routes that do not seem
to be secure since they don't need passwords but then, security with those
tools/protocols is at an other level. Have a look at other protocols like
uucp or rcp.

THen, if ftp is the protocol to use, I know a tool called 'snarf'. It
transfers files with the ftp or http protocol and works none-interactive. It
accepts urls in the form ftp://user:passwd@remotemachine/file/to/transfer.

> echo "lcd" $4 # change local directory
> echo "cd" $5 # change directory up one level
> echo "$6 $7" # put or get the file
> echo "close" # close the ftp connection
> echo "bye" # terminate ftp
> } | ftp -n >> /usr/tmp/ftpsendlog.$$
> #
> # end of ftpsend.sh
> ================================
>
> When I run the script I pass in the appropriate parameters.
> For example:
>
> Server: server1
> UserID: user
> Password: pwd
> Local Directory: /usr/tmp
> Remote Directory: /files
> Filename: file1
>
> To PUT the file:
> # ./ftpsend.sh server1 user pwd /usr/tmp /files put file1.

Stop your script and have a look at `snarf`.
(http://hpux.tn.tudelft.nl/hppd/hpux/Networking/FTP/snarf-7.0/ for hpux)

I think it does what your script should do and a little more.

If you read the documentation with snarf, keep in mind, the base of an url
is:

<protocol>://[<username>[:<passwd>]@]<machinename>[.domainname]/[[absolute/p
ath/to/]<target>]

Omited values are asked for if not given and no default is available and the
action needs the value.

CBee

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:27 EDT