[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] DNS query på MX record.



On Fri, 29 Oct 1999, Carsten Svaneborg wrote:

> Tja. Du kan save dit brev til en fil og system("/sbin/sendmail
> <brevfil")

[...]

Du glemte den letteste og (det meste af tiden) bedste løsning: popen.

int status
FILE *fp;

// start sendmail, lad den læse headere fra brevets krop
fp = popen("/usr/lib/sendmail -t", "w");
if (!fp) {
	// fejl!
	...
}

fprintf(fp, 
"From: sslug@sslug"
"To: Carsten Svaneborg <sslug@sslug>\n");
"Subject: Blah blah\n"
"\n\n"
"Dette er brevets krop\n");

status = pclose(fp);

// Check status for at se om der gik noget galt



popen laver en pipe + fork + exec, og sætter standard stdio ting op, og
styrer al det med processer osv for dig. Du behøver ikke at lave
temporære filer.

Se man popen for mere information.


-- 
==============================================================================
Erwin Andreasen   Herlev, Denmark <sslug@sslug>          UNIX System Programmer
<URL:http://www.andreasen.org>              <*>              Goodbye, Richard!
==============================================================================






 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *