telnet in a shell script

Craig Campbell craig at attcan.UUCP
Tue Nov 20 06:35:09 AEST 1990


In article <7006:Nov1408:13:3290 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>In article <8026 at muffin.cme.nist.gov> libes at 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 <cr> keystroke really that much more expensive than a <sp> 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




More information about the Comp.unix.questions mailing list