Re: How to run the mailx command in 4GL
Posted in 2010
On 16/08/10 10:18, Long Nguyen wrote: > Hi all, > I tried to run the mailx command in 4GL to send emails without sucess: > > Main > > define > > lv_text > char(100), > > lv_recipients > char(200), > > lv_subject > char(100), > > scratch > char(1024) > > let lv_text = email contents > > let lv_subject = email subject > > let lv_recipients = email_addr1 email_addr2 > > let scratch = echo ,\\\\, lv_text clipped, \\\\, > > | mail x s lv_subject lv_recipients > > run scratch clipped. > > end main > > ==================== > > The run command results in a run time error: I know the > contents of lv_subject and lv_recipients are not translated by mailx. In a > unix > script I can used variables with the $ sign but in 4GL I have to hard code the > contents of lv_subject and lv_recipients after the mailx, which I dont want to > do as their contents are not constant. > > Is there any sample code to guide me? > > Thanks a lot.Long NguyenInfomrix AP > SydneyAustralia. > if you go to my 4glworks web site (see sig) under the tools section, there's a full blown email/nntp client for 4gl called 4gwMail. If you go and get that, that might give you an idea of how to interface with an mail transfer agent like sendmail. Yes that's right: rather than battle with the vagaries of whichever user agent you care to use, the easiest thing is to put recipients and subjects straight as email header and pass the whole thing from the standard input to the transfer agent. In your case, it might be something as easy as running /usr/lib/sendmail -t <<! To: somebody Subject: whatever thought you might be interested to know.... ! Which you would collate under 4gl. Also, you don't really need to battle with assembling weird command lines in 4gl and passing them to the RUN command. If you go to the IIUG software repository and get fglio, you can open pipes straight from 4gl and read/write text straight from/to them. -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm