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: ***@gmail.com [mailto:***@gmail.com] On Behalf Of Michael
Barton
Sent: Sunday, April 13, 2008 12:30 PM
To: Nathan Kodak
Cc: ***@rom.org
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);
}
Post by ValnirHey 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
-----------------------------------
http://www.legendofthenobles.com
telnet://play.legendofthenobles.com:5400
--
ROM mailing list
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
***@rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom