Cover V04, I03
Article
Listing 1
Listing 2

may95.tar


Listing 1: mcftp--ftp for a Macintosh

#!/bin/ksh
######################################################################
# mcftp - Mac File Transfer Process                                  #
#                                                                    #
# Date      : 11-16-93                                               #
# Written by:                                                        #
# Donald C. Stone                                 _/_/_/_/_/ _/_/    #
# Information Systems Analyst                    _/_/       _/_/     #
# California Department of Transportation       _/_/   _/_/_/_/_/_/  #
# District 03 Main Office                      _/_/       _/_/       #
# 703 'B' Street                              _/_/_/_/_/ _/_/  _/    #
# Marysville, California, USA 95901                     _/_/_/_/     #
# Phone: (916)741-4031                                               #
# Email: dstone%trmx2@dot.ca.gov                   Caltrans          #
#                                                                    #
#                                                                    #
# Define the below varibles TCP and DIR.  TCP represents the IP      #
# address of the Mac and DIR represents the full pathname of a       #
# folder on the same Mac.  The folder should be accessible by        #
# GUESTs from other Mac's.  Execute this script without parameters   #
# to obtain user-level instructions and a list of options.           #
#                                                                    #
######################################################################

### Define version.  ###
PRG="Mac File Transfer Process"
VER="1.0"

### Define header,spacing, and other. ###
HDR="%%McFTP:"
HSP="        "
TYP="ascii"
COM="/tmp/mcftp.com"
TMP="/tmp/mcftp.tmp"
OPT="$1"
MF1="$2"
MF2="$3"

if [ ! "$MF2" ]; then MF2="$MF1"; fi

### TCP address and directory of remote Mac server. ###
TCP="000.000.000.000"
DIR="/Folder Name/"

echo "$HDR $PRG $VER"

### Get file to remote Mac server. ###
if [ "$OPT" = "-g" -o "$OPT" = "-gb" -o "$OPT" =
"-bg" ]; then
if [ "$OPT" = "-gb" -o "$OPT" = "-bg" ]; then
TYP="binary"
fi
echo "$HSP Remote server    - $TCP"
echo "$HSP Remote directory - $DIR"
echo "$HSP Get $MF1 $MF2"
echo "$HSP Attempting $TYP file transfer ...\c"
echo "cd \042$DIR\042"                 >  $COM
echo "$TYP"                            >> $COM
echo "get \042$MF1\042 \042$MF2\042"   >> $COM
ftp -vni $TCP                          <  $COM > $TMP 2> $TMP
echo "\n$HDR FTP Information:"
cat $TMP |
while read LINE; do
echo "$HSP $LINE"
done

### Send file from remote Mac server. ###
elif [ "$OPT" = "-s" -o "$OPT" = "-sb" -o "$OPT" =
"-bs" ]; then
if [ -f "$MF1" ]; then
if [ "$OPT" = "-sb" -o "$OPT" = "-bs" ]; then
TYP="binary"
fi
echo "$HSP Remote server    - $TCP"
echo "$HSP Remote directory - $DIR"
echo "$HSP Send $MF1 $MF2"
echo "$HSP Attempting $TYP file transfer ...\c"
echo "cd \042$DIR\042"                 >  $COM
echo "$TYP"                            >> $COM
echo "send \042$MF1\042 \042$MF2\042"  >> $COM
ftp -vni $TCP                          <  $COM > $TMP 2> $TMP
echo "\n$HDR FTP Information:"
cat $TMP |
while read LINE; do
echo "$HSP $LINE"
done
else
echo "$HSP $MF1 does not exist!\07"
fi

### List files on remote Mac server. ###
elif [ "$OPT" = "-l" ]; then
echo "$HSP Remote server    - $TCP"
echo "$HSP Remote directory - $DIR"
echo "$HSP Compiling file list ...\c"
echo "cd \042$DIR\042"    >  $COM
echo "ls"                 >> $COM
ftp -vni $TCP             <  $COM > $TMP 2> $TMP
echo "\n$HDR FTP Information:"
cat $TMP |
while read LINE; do
echo "$HSP $LINE"
done

### HELP information on sending/getting files. ###
else
echo "$HSP This program will transfer ascii/binary files"
echo "$HSP between the Mac and Unix worlds. Files are"
echo "$HSP copied to a Mac file server from where Mac"
echo "$HSP users can access it with the standard point-"
echo "$HSP and-click capability. The return process is"
echo "$HSP the same, files are copied from the Mac file"
echo "$HSP server to the current or specified directory.\n"
echo "$HSP Examples:"
echo "$HSP $ mcftp -g filename    (gets file from Mac)"
echo "$HSP $ mcftp -s filename    (sends file to Mac)"
echo "$HSP $ mcftp -l             (lists files on Mac)"
echo "$HSP $ mcftp -h             (help information)\n"
echo "$HSP Adding a \042b\042 to the \042-g\042 or \042-s\042 options will"
echo "$HSP transfer files as binary (eg. -gb or -sb)."
echo " "
echo "$HSP NOTE:"
echo "$HSP This program (mcftp) transfers files as"
echo "$HSP ascii or binary types. It does not trans-"
echo "$HSP late or convert data within the file."
fi

rm -f $COM $TMP
echo "$HDR [!]"
### The end! ###