Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mailrus!ames!pasteur!ucbvax!NUSVM.BITNET!GBOPOLY1 From: GBOPOLY1@NUSVM.BITNET (fclim) Newsgroups: comp.sys.apollo Subject: gethostname (was: gpr_$borrow mode and ^q) Message-ID: <8809151145.AA14821@umix.cc.umich.edu> Date: 15 Sep 88 11:24:58 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 39 X-Unparsable-Date: Thu, 15 Sep 88 19:18:16 SST hi, it looks like i will be answering one of my questions in an earlier inquiry. previously, i wrote: > my program also needs to write to a file in /tmp. i need the >full absolute pathname of this file right from the network root //. >so i use the unix system call, gethostname(host, strlen(host)). >but this returns -1 and *host == NULL. > > before adding the above code to my program, i used hostname(1). >at a csh level, i issued > % hostname > wm >so i expect gethostname(host, strlen(host)) to return 0 and put >"wm" into host. > > when we set up our network, we use the aegis commands like >uctnode and ctnode. we did not use hostname. i fixed this by using name_$get_path(). suppose my filename is in buf: char bar[256]; sprintf(bar, "/tmp/lock-%s", pp->pw_name); then the following char foo[256]; short len; name_$get_path(bar, (short)strlen(bar), foo, len, status); printf("%sn", foo); will produce //wm/sys/node_data/tmp/lock-fclim (the output is actually in upper case; i'm too lazy here to shift.) since we have crl /tmp `node_data/tmp on node //wm. fclim --- gbopoly1 % nusvm.bitnet @ cunyvm.cuny.edu computer centre singapore polytechnic dover road singapore 0513.