Hey all... thanks for all your input. I also received some off-list
assistance from Dale yesterday and was able to come up with the answer. I
was trying to scan for duplicate email addresses in our user accounts and
here is the final function that is working perfectly.

bool check_dup_email ( DESCRIPTOR_DATA *d, char *email )
{
    FILE *fp;
    char buf[MSL], cmd[MIL];
    bool duplicate = FALSE;
        
    write_to_buffer( d, "Please wait while we scan for duplicate
accounts....\n\r", 0 );
    sprintf( cmd, "grep -i '%s' %s*.usr\n", email, USER_DIR );
                
    if ( ( fp = popen( cmd, "r" ) ) == NULL )   
    {
        bug( "check_dup_email: Error opening shell!", 0 );
        return FALSE;
    }
    else
    {
        fgets( buf, sizeof(buf), fp );
         
        if ( strstr( buf, ".usr" ) )
        {
            sprintf( buf, "Attempt to use duplicate email address (%s)
detected.", email );
            log_string( buf );
            duplicate = TRUE;
        }
  
        pclose( fp );
    }
 
    return (duplicate);
}

- Valnir


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael
Barton
Sent: Sunday, April 13, 2008 12:30 PM
To: Nathan Kodak
Cc: [email protected]
Subject: Re: popen output

It's basically like reading from any other file.
So you can do something like:

  FILE *fp = popen("/bin/ls -l", "r");
  char line[1024];

  while (fgets(line, sizeof(line), fp))
  {
    printf("line: %s", line);
  }


On Sat, Apr 12, 2008 at 8:39 AM, Valnir <[EMAIL PROTECTED]>
wrote:
> Hey guys.. hopefully someone still watches this list.. I need to be able
to
>  read the output from a popen pipe. Can someone tell me how? Thanks!
>
>  Valnir
>  Head Coder
>  Legend of the Nobles
>  -----------------------------------
>  [EMAIL PROTECTED]
>  http://www.legendofthenobles.com
>  telnet://play.legendofthenobles.com:5400
>
>
>  --
>  ROM mailing list
>  [email protected]
>  Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>

-- 
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to