1

I've written a code where it will check the successful execution of the last run command and will mail the output with the subject.

#!/bin/ksh

SCHEDULER ID="abc123"
RUNNUM_INFO="1212"
DATE=`date '+%Y%m%d'`
FILE="OX_{DATE}.txt"

/usr/bin/ftp -n 93.179.136.9 << !EOF!
user abc passwd
cd "/0009/Codici Migrazione"
bin
get $FILE
bye
!EOF!


if [ $? -eq 0 ];
then
echo "Activity completed. \n
SCHEDULER ID : $SCHEDULE_ID \n BILL_RUN_NUM: $BILL_RUNNUM_INFO \n DATE: $DATE" | mailx -r "[email protected]" -s "Activity Completed - $DATE"
exit 0
fi

But, on executing the script, I'm getting error:

The flags you gave are used only when sending mail.
0

1 Answer 1

1

Try adding a destination/To: email address, eg:

mailx -r "[email protected]" -s "Activity Completed - $DATE" [email protected]

You'll also want to review your variables as you've got a couple issues:

1 - SCHEDULER ID="abc123" => not a valid variable; then it looks like you're trying to reference it later via $SCHEDULE_ID (valid variable name, but different spelling)

2 - RUNNUM_INFO => valid variable name, but later you try to reference it via $BILL_RUNNUM_INFO (valid variable name, but different spelling)

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks :-) had not added destination email address, have now corrected variable names.
Can I give multiple email ids in the destination? Like below: mailx -r "[email protected]" -s "Activity Completed - $DATE" [email protected] [email protected] [email protected] will it work?
Yes, you can stipulate multiple recipients/destinations; have you tried it? ("When in doubt, try it out!"); I believe mailx will accept the addresses separated by a space or comma (not at a unix command line at the moment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.