我已经编写了一个代码,它将检查上一次运行命令的成功执行,并将输出与主题一起邮寄。
#!/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 "ashish@xyz.com" -s "Activity Completed - $DATE"
exit 0
fi
但是,在执行脚本时,我收到了错误:
The flags you gave are used only when sending mail.
答案 0 :(得分:1)
尝试添加目的地/收件人:电子邮件地址,例如:
mailx -r "ashish@xyz.com" -s "Activity Completed - $DATE" recipient@abc.com
您还需要检查变量,因为您遇到了几个问题:
1 - SCHEDULER ID =“abc123”=&gt;不是有效的变量;然后看起来你试图通过$ SCHEDULE_ID(有效的变量名,但拼写不同)来引用它
2 - RUNNUM_INFO =&gt;有效的变量名称,但稍后您尝试通过$ BILL_RUNNUM_INFO(有效变量名称,但拼写不同)引用它