| 1 | #! /bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | # original from:
|
|---|
| 4 | #
|
|---|
| 5 | # @(#) frcp.ksh 2.2 93/11/14
|
|---|
| 6 | # 92/06/29 john h. dubois iii ([email protected])
|
|---|
| 7 | # 92/10/14 Cleaned up, improved, added -d and -r options
|
|---|
| 8 | # 92/11/11 Made work with a dest of '.'
|
|---|
| 9 | # 93/07/09 Added -l and -n options, & login as anonymous if no .netrc entry
|
|---|
| 10 | # 93/11/14 Use either passwd or password in .netrc, since ftp does.
|
|---|
| 11 | #
|
|---|
| 12 | # conversion to bash v2 syntax by Chet Ramey
|
|---|
| 13 | #
|
|---|
| 14 | # frcp: ftp front end with rcp-like syntax.
|
|---|
| 15 | # Note: requires any machine names given to be listed with
|
|---|
| 16 | # user and password in .netrc. If not, anonymous FTP is
|
|---|
| 17 | # done.
|
|---|
| 18 | #
|
|---|
| 19 | # full path to ftp binary
|
|---|
| 20 | if [ -x /usr/bin/ftp ]; then
|
|---|
| 21 | FTP=/usr/bin/ftp;
|
|---|
| 22 | elif [ -x /usr/ucb/ftp ]; then
|
|---|
| 23 | FTP=/usr/ucb/ftp
|
|---|
| 24 | else
|
|---|
| 25 | FTP=ftp
|
|---|
| 26 | fi
|
|---|
| 27 |
|
|---|
| 28 | istrue()
|
|---|
| 29 | {
|
|---|
| 30 | test 0 -ne "$1"
|
|---|
| 31 | }
|
|---|
| 32 | isfalse()
|
|---|
| 33 | {
|
|---|
| 34 | test 0 -eq "$1"
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | # For each filename given, put the filename in filename[n]
|
|---|
| 38 | # and the machine it is on in machine[n].
|
|---|
| 39 | function SplitNames {
|
|---|
| 40 | typeset file
|
|---|
| 41 | typeset -i i=1
|
|---|
| 42 |
|
|---|
| 43 | unset filename[*] machine[*]
|
|---|
| 44 | for file; do
|
|---|
| 45 | case "$file" in
|
|---|
| 46 | *:*) machine[i]=${file%%:*} ;;
|
|---|
| 47 | *) machine[i]=$LocalMach ;;
|
|---|
| 48 | esac
|
|---|
| 49 | filename[i]=${file#*:}
|
|---|
| 50 | let i+=1
|
|---|
| 51 | done
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
|
|---|