Path: utzoo!attcan!uunet!decwrl!elroy.jpl.nasa.gov!ncar!stout.atd.ucar.edu!thor From: thor@stout.atd.ucar.edu (Rich Neitzel) Newsgroups: comp.windows.x Subject: Re: Setting up DISPLAY environment variable Message-ID: <7956@ncar.ucar.edu> Date: 11 Jul 90 18:46:07 GMT References: <143@percival.albany.edu> Sender: news@ncar.ucar.edu Reply-To: thor@stout.atd.ucar.edu (Rich Neitzel) Organization: National Center for Atmospheric Research Lines: 35 In article <143@percival.albany.edu>, narten@percival.albany.edu (Thomas Narten) writes: |>In article <9173@uswat.UUCP> bar@uswat.uswest.com (Bala Ramakrishnan 595-2868) writes: |>>My .cshrc file has : setenv DISPLAY localhost:0 |>> |>>However, when I rlogin to the sparc server, the same .cshrc file gets |>>executed and DISPLAY is set to localhost:0. When I am on the sparc |>>server, my .cshrc file should set DISPLAY to :0 |> |>Setting DISPLAY in either .cshrc or .login is asking for trouble. Well, I disagree. I do set DISPLAY in my .login, but only if the TERM is an xterm. Then I know that the original host is running X (of course, if you rlogin from the second host to a third it fails!). Here's what I do: if ($TERM == "xterm") then if ($?DISPLAY) then exit 0 else setenv DISPLAY `who am i | tr -s '('')'' ''\011' ' ' | cut -f6 -d" " \ | cut -d"." -f1`":0" endif endif The first tr removes multiple spaces and any tabs (SunOs 4.1 who am i puts out both!). The second cut is used to correctly parse fully qualified names and simple names (i.e, it handles surt & surt.atd.ucar.edu correctly). I've only done this on Sun-3/4s under SunOs 4.0.3 & 4.1. Richard Neitzel thor@thor.atd.ucar.edu Torren med sitt skjegg National Center For Atmospheric Research lokkar borni under sole-vegg Box 3000 Boulder, CO 80307-3000 Gjo'i med sitt shinn 303-497-2057 jagar borni inn.