sendme -- fetch usenet articles by Message-ID

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Jan 3 03:28:46 AEST 1991


In article <EMV.91Jan1202420 at crane.aa.ox.com> emv at ox.com (Ed Vielmetti) writes:
> #     	sendme 1234 at host.domain.org
> #	sendme "<1234 at host.domain.org>"
> #     	sendme 1234 at host.domain.org nntpserver.domain.org
> #	sendme "<1234 at host.domain.org>" nntpserver.domain.org
  [ fifty-plus lines of perl ]

This twenty-line sh script does the same thing in roughly the same way:

  #!/bin/sh
  case "$1" in
  '<'*'>') ART="$1"; export ART ;;
  *) ART="<$1>"; export ART ;;
  esac
  authtcp -- "${2-nntpserver.domain.org}" nntp sh -c '
    exec <&6                             # read input from network
    read response
    case "$response" in
    20*) echo article "$ART"^M >&6       # say what article we want
         read response
         case "$response" in
         22*) awk '\''/^\..$/ { exit }
  	              { print } '\'' ;;  # done!
         *) echo "$response" >&2 ;;      # oops, article no good
         esac ;;
    *) echo "$response" >&2 ;;           # oops, server not ready
    esac
    echo QUIT^M >&6
  ' | sed 's/.$//'                       # strip CRs

Note that the two ^Ms should be typed as the control character. Both
scripts should actually read further and look for a sudden quit by the
server, but that never happens in practice.

authtcp was published in comp.sources.unix volume 22.

---Dan



More information about the Alt.sources mailing list