<> <> <> DIRECTORY Commander, IO, Pup, PupName, Rope; HostName: CEDAR PROGRAM IMPORTS Commander, IO, PupName = { ROPE: TYPE = Rope.ROPE; HostNameCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] --Commander.CommandProc-- = { cmdStream: IO.STREAM _ IO.RIS[cmd.commandLine]; someArgs: BOOL _ FALSE; FOR i: INT _ cmdStream.SkipWhitespace[], cmdStream.SkipWhitespace[] WHILE NOT cmdStream.EndOf[] DO ENABLE PupName.Error => { cmd.err.PutF[" %g ", IO.rope[text]]; LOOP; }; host: ROPE _ cmdStream.GetTokenRope[IO.IDProc].token; name: ROPE; address: Pup.Address; someArgs _ TRUE; address _ PupName.NameLookup[host, Pup.nullSocket]; name _ PupName.HisName[address]; cmd.out.PutF[" %g(%g)", IO.rope[name], IO.rope[PupName.AddressToRope[address]]]; ENDLOOP; IF NOT someArgs THEN { cmd.out.PutF["%g(%g)", IO.rope[PupName.MyName[]], IO.rope[PupName.MyRope[]]]; }; cmd.out.PutRope["\n"]; }; Commander.Register["HostName", HostNameCmd, "gives name and address of given hosts, or self if no args"]; }.