From: pbs@zuunix.zuo.dec.com (Philip Shearer @ZUO-DC EBS-Team)
Subject: Re: Any script for setting the DISPLAY variable?
Date: 5 Oct 1994 15:49:11 GMT [thread overview]
Message-ID: <36uhtn$5du@mrnews.mro.dec.com> (raw)
In-Reply-To: 35s3f6$4es@bigdog.fred.net
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 <stdio.h>
#include <utmp.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#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.
next prev parent reply other threads:[~1994-10-05 15:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-09-22 14:13 Any script for setting the DISPLAY variable? news
1994-10-03 21:11 ` Ben Taylor
1994-10-04 16:16 ` Stefan Monnier
1994-10-05 18:05 ` John Vanderpool
1994-10-06 15:24 ` Yair Friedman
1994-10-08 14:07 ` Stefan Monnier
1994-10-05 15:49 ` Philip Shearer @ZUO-DC EBS-Team [this message]
1994-10-06 15:49 ` Sean J. Anaya
1994-10-07 15:50 ` Georges Dubus
1994-10-07 16:07 ` Q. Alex Zhao
1994-10-06 13:30 ` Mario Klebsch DG1AM
1994-10-06 18:37 ` Michael Meissner
1994-10-07 20:38 ` Greg Walker
1994-10-10 16:33 ` Mario Klebsch DG1AM
1994-10-13 14:07 ` Greg Walker
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox