Xref: utzoo comp.unix.admin:557 comp.unix.questions:27016 comp.unix.shell:929 Path: utzoo!attcan!craig From: craig@attcan.UUCP (Craig Campbell) Newsgroups: comp.unix.admin,comp.unix.questions,comp.unix.shell Subject: Re: telnet in a shell script Message-ID: <13064@vpk1.UUCP> Date: 19 Nov 90 19:35:09 GMT References: <3886@male.EBay.Sun.COM> <8026@muffin.cme.nist.gov> <7006:Nov1408:13:3290@kramden.acf.nyu.edu> Reply-To: craig@vpk1.ATT.COM (Craig Campbell) Organization: AT&T Canada Inc., Toronto Lines: 36 In article <7006:Nov1408:13:3290@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >In article <8026@muffin.cme.nist.gov> libes@cme.nist.gov (Don Libes) writes: >Here waitfor is a dumb program along the lines of > extern char *malloc(); main(argc,argv) int argc; char *argv[]; { > int len; char *s; int pos; char ch; int f; int p; if (!argv[1]) > exit(1); len = strlen(argv[1]); if (!(s = malloc(len))) exit(2); > pos = 0; f = 0; while (read(0,&ch,1) == 1) { if (write(2,&ch,1) != 1) > exit(3); if (ch) { s[pos] = ch; pos++; if (pos == len) { f = 1; > pos = 0; } if (f && (ch == argv[1][len - 1])) { for (p = 1; > s[(pos + p) % len] == argv[1][p];p++) ; if (!argv[1][p]) exit(0); > } } } exit(4); } >Btw, Don, this is an example of what I meant by jury-rigging. Obviously >I only bothered to write waitfor once; it might be better to use a more >general tool (Perl, perhaps) to do the job, but waitfor isn't sluggish. >---Dan Wow, I'm suprised that you would post code to the net looking like that!! (Actually, I'm suprised anyone would write code that looked like that.) Why did you do that? Is a keystroke really that much more expensive than a keystroke? Oh wait!!! I've got it!! You crunched up some beautiful code just to conserve net bandwidth and allow the display of the entire program on one screen! Thanks for the thought, but I suspect resources aren't running that short yet!! I'm glad I figured that one out.... craig