home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 14917 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.7 KB  |  69 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!mlb.semi.harris.com!controls.ccd.harris.com!sak
  3. From: sak@controls.ccd.harris.com (Scott Kassan)
  4. Subject: Re: FTP - macros and macdef
  5. Message-ID: <1992Dec23.124123.5765@ccd.harris.com>
  6. Originator: sak@rs2
  7. Keywords: FTP Macro Macdef
  8. Sender: sak@controls (Scott Kassan)
  9. Organization: Harris Controls
  10. References:  <1992Dec22.202855.20553@magnus.acs.ohio-state.edu>
  11. Date: Wed, 23 Dec 1992 12:41:23 GMT
  12. Lines: 55
  13.  
  14.  
  15. The ftp on my system supports a .netrc file and a special macro called init
  16. that gets invoked upon startup.  I wrote the following script to automate
  17. the transfer of many files from one machine to another.  I'm not sure if
  18. these features are supported on all platforms, but I thought it was worth
  19. mentioning.
  20.  
  21. --------------------------- cut here ------------------------------------
  22. if [ "$1" = "" ]
  23. then
  24.     echo "USAGE: ftp.script nodename"
  25.     exit
  26. fi
  27.  
  28. if [ -f $HOME/.netrc ]
  29. then
  30.     cp $HOME/.netrc /tmp/$$
  31.     RESTORE="cp /tmp/$$ $HOME/.netrc ; rm /tmp/$$"
  32. else
  33.     RESTORE="rm $HOME/.netrc"
  34. fi
  35.  
  36. cat > $HOME/.netrc <<!END
  37. machine $1
  38. macdef tx
  39. put "|cat \$1 2> /dev/null || get -p -s s.\$1" \$2
  40.  
  41. macdef t
  42. \$tx \$1 \$1
  43.  
  44. macdef t2
  45. \$tx \$1 \$2
  46.  
  47. macdef init
  48. !$RESTORE
  49. hash
  50. cd $SYST
  51. lcd $PROJ/../..
  52. ascii
  53. put file1
  54. \$t file2
  55. \$t2 file3
  56. quit
  57.  
  58. !END
  59. #
  60. # note: the blank line before !END is required to end the definition
  61. #       of the init macro
  62. #
  63. ftp $1
  64. ------------------------------------- cut here ---------------------------
  65. -- 
  66. Scott Kassan                    | "And all this science I don't understand
  67. email: s.kassan@ccd.harris.com  |  It's just my job five days a week"
  68.                                 |    -- Elton John, "Rocket Man"
  69.