Desktop productivity for business analysts and programmers

Not getting mail from sas Job when running on Unix SAS Grid

Reply
Contributor
Posts: 66

Not getting mail from sas Job when running on Unix SAS Grid

When I'm running below code in EG it is working fine [Abort Job and send error to mail id] but when same Program I'm running thru Unix SAS Grid it is not sending mail, Please help me out.. Thanks

 

Test_mail.sas : 


%macro errmail;
;run;quit;
%if %eval(&syserr > 4) %then
%do;
data _null_;
filename myfile email
to=("email_id@chk.com")
subject= "Subject Line_Test "

type="text/plain";

file myfile;
put 'Your job received the following ERROR/WARNING message:';
put;
put 'ERROR was:';
put "&syserrortext";
put;
put 'WARNING was:';
put "&syswarningtext";
run;
%abort cancel;
%end;
%mend errmail;

data ds1;
set ds2;
%errmail;

 

 

Below Command I'm using on Unix SAS Grid : 

 

 

sasgsub -gridwait -gridsubmitpgm test_mail.sas

 

Above command runs and abort the sas program which I want but not sending mail, as EG sending me the mail. 

 

 

 

 

Super User
Posts: 8,055

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

Make sure that all grid members have email correctly set up. Write a short program that sends email without aborting, run that in batch, and look at the log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 66

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to KurtBremser

Thanks Kurt for replying, I'm able to send mail thru Unix without aborting statement, how can I send mail with abort statement as it is working in EG. 

 

%macro errmail;
data _null_;
filename myfile email
to=("mail_id")
subject= "subject "

type="text/plain";

file myfile;
put 'Your job received the following ERROR/WARNING message:';
put;
put 'ERROR was:';
put "check2";
put;
put 'WARNING was:';
put "check1";
run;

%mend errmail;

%errmail;

Super User
Posts: 8,055

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

I have the suspicion that your use of %abort cancel is the reason.

In batch mode, %abort cancel causes an immediate termination of the SAS job; since sending mail requires that SAS start an external command to hand the mail over to, the premature termination of SAS might cause this action to not be performed IMO.

(in workspace server mode, the SAS session is not terminated, only the submitted code)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 8,055

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

Have you tried to explicitly close the file?

%macro errmail;
;run;quit;
%if %eval(&syserr > 4)
%then %do;

  filename myfile email
    to=("email_id@chk.com")
    subject= "Subject Line_Test "
    type="text/plain"
  ;

  data _null_;
  file myfile;
  put 'Your job received the following ERROR/WARNING message:';
  put;
  put 'ERROR was:';
  put "&syserrortext";
  put;
  put 'WARNING was:';
  put "&syswarningtext";
  run;

  filename myfile clear;

  data _null_;
  abort cancel;
  run;
%end;
%mend errmail;

data ds1;
set ds2;
%errmail;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 66

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to KurtBremser

Thanks but this also not working, when I'm running " only %errmail; then it is sending me mail from unix (after removing condition). but not sending me mail from unix when I put condition in it (&syserr).. In EG working fine. 

 

I don't know what is happening Smiley Sad

%errmail;

"

Super User
Posts: 8,055

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

Run the batch job and use %put to reveal the contents of &syserr at the relevant stages; it might be that you get a value of 3 instead of the expected > 4.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 8,174

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

From the documentation:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002592796.htm

"You can send electronic mail programmatically from SAS using the SMTP (Simple Mail Transfer Protocol) e-mail interface. SMTP is available for all operating environments in which SAS runs. To send SMTP e-mail with SAS e-mail support, you must have an intranet or Internet connection that supports SMTP."

 

So I would say without any information that you are missing something on the Unix system.  Consult with your IT, perhaps its just a permission, perhaps they need to make something available.

Contributor
Posts: 66

Re: Not getting mail from sas Job when running on Unix SAS Grid

Thanks RW9,

 

I'm able to send mail thru SAS Code from Unix but in this particular case I'm not getting mail, although that code is perfectly fine in SAS EG. 

Community Manager
Posts: 3,017

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

Ensure that all EMAIL* options are set either in your program or in the autoexec for each grid session -- naming EMAILHOST, port, etc...

 

options emailhost='mailserver.company.com' emailsys=smtp;

 

It might be that when running in the grid, these aren't initialized and are resorting to the default settings.

Contributor
Posts: 66

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to ChrisHemedinger

below macro is sending the mail from grid, but not the one I had issue and on EG it is working find. 

 

%macro errmail;
data _null_;
filename myfile email
to=("mailid")
subject= "test_subj "

type="text/plain";

file myfile;
put 'Your job received the following ERROR/WARNING message:';
put;
put 'ERROR was:';
put "check2";
put;
put 'WARNING was:';
put "check1";
run;

%mend errmail;

%errmail;

Community Manager
Posts: 3,017

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to atul_desh

Run this code to check your e-mail options:

 

proc options group=email; run;

Check this within your EG environment and within your server/batch environment -- compare the results and see if you might need to explicitly set some of the EMAIL* options to make it work the way you need.

Contributor
Posts: 66

Re: Not getting mail from sas Job when running on Unix SAS Grid

Posted in reply to ChrisHemedinger
Both are exactly same Smiley Sad


Batch O/p :

Group=EMAIL
EMAILACKWAIT=30 Specifies the number of seconds to wait for the SMTP server acknowledgement.
EMAILAUTHPROTOCOL=NONE
Specifies the SMTP e-mail authentication protocol.
2 The SAS System 09:54 Tuesday, November 28, 2017

NOEMAILFROM Does not require the FROM e-mail option when sending e-mail by using the FILE or FILENAME statements.
EMAILHOST=something.com (can't disclose)
Specifies one or more domain names for SMTP e-mail servers.
EMAILID= Specifies the SAS user's logon ID, profile or e-mail address.
EMAILPORT=25 Specifies the port number for the SMTP e-mail server that is specified in the EMAILHOST option.
EMAILPW=XXXXXXXX Specifies the password for the e-mail address specified by the EMAILID option.
EMAILUTCOFFSET= For SMTP e-mail sent using the FILENAME statement, specifies a UTC offset that is used in the Date header field
of the e-mail message.
EMAILSYS=SMTP Specifies the e-mail protocol that is used for sending electronic mail.


EG O/P :

Group=EMAIL
EMAILACKWAIT=30 Specifies the number of seconds to wait for the SMTP server acknowledgement.
EMAILAUTHPROTOCOL=NONE
Specifies the SMTP e-mail authentication protocol.
NOEMAILFROM Does not require the FROM e-mail option when sending e-mail by using the FILE or FILENAME statements.
EMAILHOST=something.com (can't disclose)
Specifies one or more domain names for SMTP e-mail servers.
EMAILID= Specifies the SAS user's logon ID, profile or e-mail address.
EMAILPORT=25 Specifies the port number for the SMTP e-mail server that is specified in the EMAILHOST option.
EMAILPW=XXXXXXXX Specifies the password for the e-mail address specified by the EMAILID option.
EMAILUTCOFFSET= For SMTP e-mail sent using the FILENAME statement, specifies a UTC offset that is used in the Date header field
of the e-mail message.
EMAILSYS=SMTP Specifies the e-mail protocol that is used for sending electronic mail.
Ask a Question
Discussion stats
  • 12 replies
  • 230 views
  • 0 likes
  • 4 in conversation