Link to home
Start Free TrialLog in
Avatar of elwayisgod
elwayisgodFlag for United States of America

asked on

Unix Help with: mailx -s

Hi,

Not familiar with Unix.  We run Autosys jobs to send some emails.  

The command we run is:

command: mailx -s "Pinnacle_load_complete_email" `cat /data/SAP/email/PinnacleEmail.lst` < /data/SAP/work/MAIL_FILE.txt

Open in new window


However it doesn't send the email.  So not sure what is happening.  I get the below in the stdout and std err:

std_err_file=/logs/autosys/$AUTO_JOB_NAME.$AUTORUN.tracelog
command=autosyslog -J TMC_SAPGL_PINNACLE-EMAIL-SEND -r 0 -n 12 -t E
===================================
CAUAJM_E_40003 The specified parameters are not valid.

CA WAAE Log Utility

USAGE: autosyslog [-e [-l | -p]]
                  [-s]
                  [-j JobName [-d DatasetName|FileName:Num | -r | -n | -t  [A|P|O|E|S] | -z]]
                  [-usr AuthUser [-pw AuthPassword | -pwx AuthEncryptedPassword] | -saml AuthArtifact]
                  [-x]
                  [-?]

WHERE: -e                             Monitor (Scheduler)
       -s                             Monitor (Application Server)
       -l                             Specifies the maximum number of lines to fetch
       -p                             Specifies a string which is used in a pattern matching algorithm to
                                      determine whether a given line of the logfile should be returned
       -j    JobName                  Job name
       -n                             Retry number (should not be negative)
       -r                             Run number
       -t                             Type of job log to fetch
                                         A=Job agent log file
                                         P=Job profile log file (legacy agent only)
                                         O=Job standard output file
                                         E=Job standard error file
                                         S=Job spool file
       -d    DatasetName|FileName:Num Retrieve the contents of a z/OS job log dataset or i5/OS job log file
       -z                             Retrieve a list of available z/OS job log types and dataset names
                                      or i5/OS job log file names.
                                      The contents of an individual log or dataset can be retrieved using
                                      the -d option.
       -usr  AuthUser                 User to authenticate with external security
       -pw   AuthPassword             Plain text password for user authentication
       -pwx  AuthEncryptedPassword    Encrypted password for user authentication
       -saml AuthArtifact             Security Assertion Markup Language (SAML) artifact
                                      for single sign-on authentication
       -x                             Returns version information
       -?                             Help

NOTE:  1. The -e, -s and the -j options are mutually exclusive.
       2. The -e and -s options when specified standalone function in a tail
          mode and must be used on the machine where the logfile resides.
       3. When using -e option with the -l or -p options the results are
          returned as if they were part of a report (does not function in a
          tail mode).
       4. The -e option when used with the -l or -p can be executed on a
          remote computer to return contents of the Scheduler logfile.
       5. The -s option does not support the -l and -p options.
       6. The -n should be used along with the -r option.
       7. Use the -d and -z options for z/OS or i5/OS job log retrieval. Run -z
          first to retrieve all available log datasets or file names followed by
          -d DatasetName|FileName:Num to retrieve the contents of an individual log dataset or file
          where the i5/OS file is specified with both name and number.
       8. The P argument of -t is only supported for legacy agents.


===================================
Avatar of arnold
arnold
Flag of United States of America image

How many recipients do you have there and is it formatted separated by commas?
One option enclose the list of recipients by double quotes this way there is no errand enter/new line.

Mailx is a GUI based mail client of mail...
echo "From: <sender@emailaddress>
To: $(cat /data/SAP/email/PinnacleEmail.txt
Subject: Pinnacle_load_complete_email

$(cat /data/SAP/work/MAIL_FILE.txt)
" |/usr/sbin/sendmail -oi -fsender@emailaddress -t

Open in new window


Note the PinnaxleEmail.txt file has to be properly formatted, comma separated list of email addresses, not the number of recipients might be an issue to be worried. If you have a distribution list such that this notice will be sent to one address that will then redistribute it to the recipients......

Your error possibly because of the way the list of recipients is provided.
Avatar of elwayisgod

ASKER

you are posting a command that is used  somewhere else but the output is seemingly unrelated to the execution of the command unless those are the contents of mailfile.txt.

See if you use mail instead of mailx does the same issue arise.

Oh, on Solaris, the sendmail is in /usr/lib/sendmail ....
Avatar of Member_2_276102
Member_2_276102

Quick guess from a quick scan -- You show { autosyslog -J } but the "USAGE" notes don't show that "-J" is valid; it should be "-j". I.e., it's a lower-case "j".
SOLUTION
Avatar of Hanno P.S.
Hanno P.S.
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Let me try both suggestions now. What's weird is I copied all the JILS from DEV so they are identical and they work in DEV.
@Hanno

Don't I need to add the -r parameter?
When I run this:
mailx -s "Pinnacle_load_complete_email" -r stoteve@ofiglobal.com < /data/SAP/work/MAIL_FILE.txt

Open in new window



I'm getting this in Std_Err
std_err_file=/logs/autosys/$AUTO_JOB_NAME.$AUTORUN.tracelog
command=autosyslog -J TMC_SAPGL_PINNACLE-EMAIL-SEND -r 0 -n 0 -t E
size=197
===================================
Send options without primary recipient specified.
Usage: mailx -eiIUdEFntBDNHRV~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users

===================================
This is a SUCCESS in DEV:

mailx -s "Pinnacle_load_complete_email" stoteve@ofiglobal.com < /data/SAP/work/MAIL_FILE.txt

Open in new window

OK.  So I got it to run to success on both DEV and UAT servers with this code.  Removed all dependencies on files so can rule that out as issue:

mailx -s "Pinnacle_load_complete_email" stoteve@ofiglobal.com

Open in new window


However only the DEV instance actually sends the email.  I never receive the email from the UAT instance.

So is it possible the 'mailx' functionality is not working on UAT server?  Or maybe the owner in Autosys 'pscron' doesn't have correct rights in UAT?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No problem at all.  I used your suggestion on the -r switch to put a valid 'From' address in the email.  It worked great.

Still won't run on UAT thus has to be something with server.  I'll ping server team to address as kind of stuck there.  And just hope it works on Prod when I deploy :)
I also ditched the 'PinnacleEmail.lst' file as that is not necessary to maintain the file and ensure it's in the correct Unix format.  Separating the email addresses by a comma works fine, right in the command line.

Appreciate the help!!
Thanks.
glad I could help !
Could it also be some problem with your mail setup on UAT ? They may want to check that, too.
Yes.  I have already logged a ticket with the Unix admins.  I'm sure its something like that.  Who knows :)