Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!uwvax!rutgers!bellcore!faline!thumper!ulysses!mhuxo!mhuxu!att!ihlpb!TSfR!usenet From: usenet@TSfR.UUCP (usenet) Newsgroups: comp.sys.atari.st Subject: Re: Con -> RS232 Summary: Fforce()/Fdup() to the rescue! Message-ID: <528@TSfR.UUCP> Date: 22 Apr 89 04:52:36 GMT References: <111500016@uxa.cso.uiuc.edu> Reply-To: orc@pell.UUCP (David L. Parsons) Followup-To: comp.sys.atari.st Organization: Department of Atomic Text Units Lines: 70 Expires: In article <111500016@uxa.cso.uiuc.edu> sfn20715@uxa.cso.uiuc.edu writes: > >I have set up an ST BBS recently and am trying to get some online games >running, specifically Larn and Nethack. However, both of these games send >output to the screen, not the RS232 port. If you're running a STadel, it attempts to redirect i/o to the rs232 port when you shell out from remote. If hack & larn still talk to the screen, you're S.O.L. unless you wanna hack the BIOS calls. If you're not running STadel, try the following code: ------[cut here]------ /* * rexec: execute a program with stdin/stdout pointed at AUX: */ #include main(argc, argv) { char tail[128]; char *command; int save0, save1; if (argc < 2) { Cconws("usage: rexec command [args]\r\n"); exit(255); } save0 = Fdup(0); /* save old file descriptors */ save1 = Fdup(1); Fforce(-2, 0); /* force AUX: (-2) into stdin (0) and stdout (1) */ Fforce(-2, 1); /* PARAMETERS MAY BE REVERSED! */ ++argv, --argc; command = *argv++; argc--; tail[0] = 0; /* fabricate a command tail */ while (argc-- > 0) { strcat(tail, " "); strcat(tail, *argv++); } if (tail[0]) tail[0] = strlen(tail)-1; Pexec(0, command, tail, 0L); /* Zoom! */ Fforce(save0, 0); /* restore stdin/stdout */ Fforce(save1, 1); Fclose(save0); /* and toss save-handles */ Fclose(save1); } ------[cut here]------ If your applications are well-behaved (talk via GEMDOS calls instead of BIOS calls), this will do the trick. I use a variant of this routine from inside STadel for shelling out, and I regularly shell out from remote (when Pell is working, that is) even if I'm calling from long distance. >Reply as e-mail to sfn20715@uxa.cso.uiuc.edu please. Hope you don't mind that I replied publicly - this sort of code is useful to the world in general... -david parsons -orc@pell.uucp