Agus Mujtahid
16th February 2011, 11:59
Dear All,
Now,we are developing program to send email via baan (Server:Unix/AIX).
We use function run.prog(),like this:
first we use this command:

remark.email="Data BO"
email.sup=mujtahid@kyb.co.id
send.email=run.prog("mail -s remark.email email.sup</d01/tmp/file.note","",RP_NOWAIT)

with the above command ,we got return value 0,but we are not received any email.

then we changed our command like this:

remark.email="Data BO"
email.sup=mujtahid@kyb.co.id
send.email=run.prog("sh","mail -s remark.email email.sup</d01/tmp/file.note",RP_NOWAIT)

the same result occured,no email received by us,please help us.
what wrong with our commands?
can we use "sh" to run shell,like our above command?
thanks

Mujtahid

litrax
16th February 2011, 12:15
Hello,

first of all: have you checked that the command on the commandline functions well? Type
mail -s Data BO mujtahid@kyb.co.id < /d01/tmp/file.note
and see what happens.

second: I always use
cat /d01/tmp/file.note | mail mujtahid@kyb.co.id
or in your case in the script
run.prog("cat /d01/tmp/file.note | mail mujtahid@kyb.co.id","",RP_NOWAIT)

If this doesn't work perhaps you can use RP_WAIT for debugging and check the return value which can be


0 program executed successfully

<0 program could not be started

>0 program did not execute successfully

Agus Mujtahid
16th February 2011, 15:18
thanks,
we have tried this command directly from unix,we type this command in shell:
mail -s "DATA BO" mujtahid@kyb.co.id</d01/tmp/file.note,
everything is ok,we get email from this unix command.
What wrong with our command,please help us.

Thanks,

litrax
16th February 2011, 15:31
Mind that with RP_NOWAIT the return value is always 0.
Try it with mode RP_WAIT .

If return value is < 0 the program is not even started (maybe cat or mail could not be found).
If return value is > 0 something went wrong with the execution.

A guess would be that you write the full path of the mail program on your server (e.g. usr/bin/mail) in the run.prog command.
Aren't there any error messages at runtime or on the server in any logfile (/var/log/mail)?

Alternatively write a little shell script that does everything and write run.prog("myshellcript",,RP_NOWAIT)

NPRao
17th February 2011, 01:58
Here is the sample code, which works in our Unix environment -

long ret
string comd(12), emailid(80), string(80), args(256)

comd = "/bin/mailx"
args = " -s " & quoted.string(trim$(subject)) & " " & emailid
ret = run.prog(comd, args, RP_WAIT, trim$(file.path))

Your code has issues -
remark.email="Data BO"
email.sup=mujtahid@kyb.co.id
send.email=run.prog("mail -s remark.email email.sup</d01tmp/file.note","",RP_NOWAIT)

The Unix shell does not know your Baan code variables contents -

run.prog("mail -s remark.email email.sup</d01tmp/file.note","",RP_NOWAIT)

Also, refer to the programmer's manual for the function usage - run.baan.prog(), run.prog() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_starting_and_stopping_programs_run_baan_prog_run_prog)

Agus Mujtahid
17th February 2011, 04:51
Dear all,
We tried with this command:
1.
send.email=run.prog("/usr/bin/mail","mail -s remark.email email.sup</d01/tmp/file.note",RP_WAIT)

in debugger we get return value=0,but no email received by us.
then we use this command:
2.
send.email=run.prog("/bin/mailx","mail -s remark.email mujtahid@kyb.co.id</d01/tmp/SLIDACD01-17022011.txt",RP_WAIT)

in debugger we get return value=0 too,but no email received by us.

detail debugger,see attachment.

what wrong with our script?
thanks

litrax
17th February 2011, 09:53
I think NPrao has the right hint for you.
Just build the string mstring = "mail -s mujtahid@kyb.co.id</d01/tmp/SLIDACD01-17022011.txt" before putting it in the run.prog command.
Then use run.prog(mstring,,RP_WAIT) (when it works with RP_NOWAIT).