Xref: utzoo news.newusers.questions:3598 alt.sources:2920 Path: utzoo!utgpu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: news.newusers.questions,alt.sources Subject: Re: sendme -- fetch usenet articles by Message-ID Summary: shorter version in sh Message-ID: <13437:Jan216:28:4691@kramden.acf.nyu.edu> Date: 2 Jan 91 16:28:46 GMT References: <1990Dec29.014722.25213@midway.uchicago.edu> <1085@toaster.SFSU.EDU> Organization: IR Lines: 37 In article emv@ox.com (Ed Vielmetti) writes: > # sendme 1234@host.domain.org > # sendme "<1234@host.domain.org>" > # sendme 1234@host.domain.org nntpserver.domain.org > # sendme "<1234@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