[DGD]External commands

Matthew Jenkins matt at esb.co.uk
Sat Mar 31 13:54:15 CEST 2001


Yep - here it is...

Drop this into one of your existing kfun files, recompile dgd, reboot, and
you should have the sendmail() function...

I'm sure the system call can be cleaned up a bit, but it does the job I
want it to, so why change? ;)

flibs

-- BEGIN --

# ifdef FUNCDEF
FUNCDEF("sendmail", kf_sendmail, pt_sendmail)
# else
char pt_sendmail[] = { C_TYPECHECKED | C_STATIC, T_VOID, 5, T_STRING,
T_STRING, T_STRING, T_STRING, T_STRING };

int kf_sendmail(f)
register frame *f;
{
        FILE *fd;
        char *command;
        command = malloc(128);
        fd = fopen("tmail","w");
        fprintf(fd,"HELO\n");
        fprintf(fd,"MAIL FROM: %s\n",f->sp[3].u.string->text);
        fprintf(fd,"RCPT TO: %s\n",f->sp[2].u.string->text);
        fprintf(fd,"DATA\n");
        fprintf(fd,"Subject: %s\n\n",f->sp[1].u.string->text);
        fprintf(fd,"%s",f->sp[0].u.string->text);
        fprintf(fd,"\n.\nQUIT\n");
        fclose(fd);
        sprintf(command,"sendmail -bs -F%s <tmail >tmail.out",
				f->sp[4].u.string->text);
        system(command);
        str_del((f->sp++)->u.string);
        str_del((f->sp++)->u.string);
        str_del((f->sp++)->u.string);
        str_del((f->sp++)->u.string);
        free(command);
        return 0;
}
#endif

-- END --

On Fri, 30 Mar 2001, Jason Murray wrote:

> >From: Lerkista <lerkista at planetatierra.net>
> >Reply-To: dgd at list.imaginary.com
> >To: <dgd at list.imaginary.com>
> >Subject: [DGD]External commands
> >Date: Fri, 30 Mar 2001 17:03:04 -0600
> >
> >There's a way to run commands of the shell of unix within the DGD??
> >I want to run a script to send mails!!
> >
> 
> Not without altering DGD source and recompiling. Though did I hear kfuns are 
> pluggable in the new DGD? Or am I thinking of something completely 
> different? Anyway, in addition to the new kfun you write, the auto object 
> would need to be modified to provide a suitable wrapper, such as who/what 
> can access the function from within DGD and so forth.
> 
> Jason
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> 
> 
> List config page:  http://list.imaginary.com/mailman/listinfo/dgd
> 


List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list