who have used utmpxname()?

who have used utmpxname()?

Post by kjpe » Wed, 09 Jan 2002 14:53:56



I want to read /var/adm/wtmpx, but when i call
utmpxname("/var/adm/wtmpx"),
it return 1 and following getutxent() still return records which is in
/var/adm/utmpx.

Why?

 
 
 

who have used utmpxname()?

Post by Logan Sh » Wed, 09 Jan 2002 17:31:21




>I want to read /var/adm/wtmpx, but when i call
>utmpxname("/var/adm/wtmpx"),
>it return 1 and following getutxent() still return records which is in
>/var/adm/utmpx.

The manual page on Solaris 8 says that getutxent() only opens the file
if it's not already open, and it also says utmpxname() only changes the
filename in memory and doesn't open or close a file.

So, I would imagine that if you call getutxent() before you call
utmpxname(), then probably utmpxname() will have no effect because the
file will already be open.

I'm not sure if you are doing that, but the wording of your post makes
it sound like possibly you are doing that.

  - Logan
--
Diamonds may be "forever", but graphite is more thermodynamically favorable.

 
 
 

who have used utmpxname()?

Post by kjpe » Wed, 09 Jan 2002 21:29:48



> I want to read /var/adm/wtmpx, but when i call
> utmpxname("/var/adm/wtmpx"),
> it return 1 and following getutxent() still return records which is in
> /var/adm/utmpx.

> Why?

My program looks like following:

 strcpy(str,"/var/adm/wtmpx");
 ret = utmpxname(str);

 setutxent();

 do {
  utx = getutxent();
 } while(utx);

 endutxent();

But i can not find any bug.

 
 
 

who have used utmpxname()?

Post by kjpe » Thu, 10 Jan 2002 19:59:46





> >I want to read /var/adm/wtmpx, but when i call
> >utmpxname("/var/adm/wtmpx"),
> >it return 1 and following getutxent() still return records which is in
> >/var/adm/utmpx.

> The manual page on Solaris 8 says that getutxent() only opens the file
> if it's not already open, and it also says utmpxname() only changes the
> filename in memory and doesn't open or close a file.

> So, I would imagine that if you call getutxent() before you call
> utmpxname(), then probably utmpxname() will have no effect because the
> file will already be open.

> I'm not sure if you are doing that, but the wording of your post makes
> it sound like possibly you are doing that.

>   - Logan

Now i use fopen() to read /var/adm/wtmpx and it work well.
Here is my codes:
        fp = fopen("/var/adm/wtmpx","r");
        while (!feof(fp)) {
                fread(utx,sizeof(struct utmpx),READ_NUM,fp)
        }
Thank for all!