From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103734,674f735b36ac5ffe X-Google-Attributes: gid103734,public X-Google-Thread: 1070f0,674f735b36ac5ffe X-Google-Attributes: gid1070f0,public X-Google-Thread: fee84,674f735b36ac5ffe X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-10-05 13:36:47 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swrinde!sgiblab!cs.uoregon.edu!usenet.ee.pdx.edu!fastrac.llnl.gov!lll-winken.llnl.gov!decwrl!pa.dec.com!mrnews.mro.dec.com!zuunix.zuo.dec.com!pbs From: pbs@zuunix.zuo.dec.com (Philip Shearer @ZUO-DC EBS-Team) Newsgroups: comp.windows.x,comp.sys.sun.admin,comp.unix.osf.osf1 Subject: Re: Any script for setting the DISPLAY variable? Date: 5 Oct 1994 15:49:11 GMT Organization: Digital Equipment Corporation - Marlboro, MA Distribution: usa Message-ID: <36uhtn$5du@mrnews.mro.dec.com> References: <35s3f6$4es@bigdog.fred.net> NNTP-Posting-Host: zuunix.zuo.dec.com X-Newsreader: Tin 1.1 PL3 Xref: bga.com comp.windows.x:12245 comp.sys.sun.admin:16910 comp.unix.osf.osf1:3886 news@bigdog.fred.net writes: : : I rlogin to HP, DEC Alpha OSF1, Sun systems. I have had : some script in .login which would set the DISPLAY variable. : But it uses the 'whoami' command to find out from which : system I have logged in. Unfortunately the output of : whomai is not the same on all these systems. Was wondering : if you folks have some script which would set the DISPLAY : environment variable correctly on ALL systems. : How about this c source, it works under OSF, (and ultrix if the host name is under 16 chars long): ----------------------X cut X--------------------------------- #include #include #include #include #include #include #include #include #define FILE_NAME "/usr/adm/wtmp" struct utmp utmp_s; int main(argc, argv) int argc; char *argv[] ; { int fd ; char *tty_name; char host_name[128] = "" ; if ( argc != 2 ) { fprintf(stderr,"usage: %s `tty`\n",argv[0]); return 1 ; } tty_name=argv[1]; if ( (fd=open(FILE_NAME,O_RDONLY )) < 0 ) { perror("opening:%s",FILE_NAME); return 1 ; } while( read(fd,&utmp_s,sizeof(utmp_s)) == sizeof(utmp_s)) { if( strlen(utmp_s.ut_line) && strstr(tty_name, utmp_s.ut_line)) strcpy(host_name,utmp_s.ut_host); } if(strlen(host_name )) printf("%s\n",host_name); else printf("\n"); close(fd); return 0 ; } ----------------------X cut X--------------------------------- -- Regards Philip Shearer Disclaimer: Please note that the above is a personal view and should not be construed as an official comment from DEC.