Eddie Monster
13th January 2006, 22:33
I use a Baan report script to create a unix shell script

#!/usr/bin/ksh
export EMAIL_TO='plantlevel_purchaser@customer.com'
export EMAIL_FROM='batchjob@mycompany.com'
export EMAIL_CC='ar.staff@mycompany.com, production.staff@mycompany.com, production.manager@mycompany.com, invoicing.clerk@mycompany.com, manager_one@customer.com, manager_two@customer.com'
export EMAIL_SUBJECT='Shipments from Oberg Industries, Inc. to Customer'
{
echo To: $EMAIL_TO
echo FROM: $EMAIL_FROM
echo CC: $EMAIL_CC
echo Subject: $EMAIL_SUBJECT
echo 'MIME-Version: 1.0'
echo 'Content-type: text/html'
echo 'Content-Transfer-Encoding: 7bit'
echo '<HTML><HEAD></HEAD><BODY><FONT SIZE=2 FACE="arial">The following items have recently shipped:'
echo ''
echo '<BR><P></P><P></P>'
echo '<TABLE BORDER=1 WIDTH=100%>'
echo '<TR><TD><B><FONT SIZE=2>Customer Reference</B></TD>'
echo '<TD><B><FONT SIZE=2>Item</B></TD>'
echo '<TD><B><FONT SIZE=2>Description</B></TD>'
echo '<TD ALIGN=RIGHT><B><FONT SIZE=2>Ship Date</B></TD>'
echo '<TD ALIGN=RIGHT><B><FONT SIZE=2>Qty Shipped</B></TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE = 2><B>Unit</B></TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE = 2><B>Qty Received</B></TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE = 2><B>PackSlip</B></TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE = 2><B>Invoice</B></TD></TR>'
echo '<TR><TD><FONT SIZE=2>AAAAAAA</TD>'
echo '<TD><FONT SIZE=2>F123-456-54654 </TD>'
echo '<TD><FONT SIZE=2>Part Description</TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE=2>1-11-2006</TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE=2>80.00</TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE=2>tho</TD>'
echo '<TD><FONT COLOR=WHITE SIZE=2> &nbsp </TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE=2>233826</TD>'
echo '<TD ALIGN=RIGHT><FONT SIZE=2>40058458</TD></TR>'
echo '</FONT></BODY></HTML>'
}|/usr/sbin/sendmail plantlevel_purchaser@customer.com, ar.staff@mycompany.com, production.staff@mycompany.com, production.manager@mycompany.com, invoicing.clerk@mycompany.com, manager_one@customer.com, manager_two@customer.com


I then use the following commands in the Baan report script to close the file, change the files permissions and then execute the file:

ret = seq.close(mail.file)
ret = shell("/${BSE}/common/customer/" & str$(lval(cuno.f)) & "mail",1)
| FOR TESTING... message("Return Value is: " & str$(ret))


If the user runs the session the file is created and the return value for the shell command is zero (successfull execution), but no e-mails are sent. If I then go into the command line and execute the file '3831mail', the e-mails get sent. Can anybody take a guess as to why the emails do not send when the user runs the script?

I chmod the file to 777 just to make sure permissions are not an issue. Our internal email addresses use a dot and the customer's use an underscore, but I wouldn't think that is the problem.

If I change the script to simply send it to two internal employees it works when I run the session, and it also works for the user, but when we try out the full array of e-mail addresses it doesn't work.

Is there a problem with the length of the sendmail command at the end of my script? I'm new to using sendmail and not very familiar with it.

Any help that anyone can offer would be greatly appreciated!

dave_23
14th January 2006, 01:29
Create an alias in /etc/mail/aliases that lists all of your email
addresses.

make sure to run "newaliases" after you do it.

I know that doesn't tell you the answer, but probably not worth messing
around with too much.

Dave

Eddie Monster
18th January 2006, 20:59
Thanks dave_23,

I set up an alias. If I run the session it works (Unix shell script files are generated and executed), but if the user runs the session it writes the files to the directory, but the shell() command does not execute them (even though the return value is 0 indicating a successful execution)... :confused:

I logged into unix as that user and was able to get to the directory without any problem.

Anything else you can think of that would be a factor?

mark_h
18th January 2006, 23:47
Does the user have permissions to execute a shell within Baan? First thing that popped into my mind. Can you shell out from Baan, cd to the directory and execute the script?

mark_h
18th January 2006, 23:49
Oops I meant from the users logon and not your own.

dave_23
19th January 2006, 01:11
I agree with Mark on that, it seems like that's maybe a "bug/flaw" in baan
shell() and ottstpconv:<shell stuff> doesn't work if you don't
have shell permissions.

Dave

Eddie Monster
19th January 2006, 18:48
Yes, that was the problem.

Usually any e-mails we have sent out is through a user called 'batchjob' and run from Job Management, but with this request, it was the user running the session and by default we do not enable that on a regular user. Once I made the change, the user was successful and the e-mails were sent.

Thank you both!

mark_h
19th January 2006, 20:55
I think this is a bug. I was just guessing. I do this in a program to send a message to users to let them know when a project is ready to be authorized.

cmd = "mailx -s " & chr$(34) &"Project " & strip$(mail.cprj) & chr$(34)& " " & strip$(mail.addr) & "<" & temp.file
rc = shell(cmd, SHELL_NO_OUTPUT)

And our users have the shell type set to no. I am not sure if there is any difference between what we are doing. No complaints yet.