Quantcast
Channel: All System Administration posts
Viewing all articles
Browse latest Browse all 1179

mailx command in Linux

$
0
0

Hi, Can anyone pls help me for below issue.

Below code is working fine in unix sever for sending mail along with attachments from an array variable i.e DISCARDED_FILE_NAME. But same code is not working in Linux sever, since -m in mail command will not be supported in linux instead of it we need to use -a. Even I have tried with it as shown below but still it is not working.

This code is working fine in Unix sever with out any issue:

MRP_NAME=$1
set -A DISCARDED_FILES $2
DISCARDED_FILE_NAME="DISCARDED"
echo "MRP_NAME" ${MRP_NAME}
RECEIVER="xyz@gmail.com"
echo "RECEIVER" ${RECEIVER}
SUBJECT="Error on ${MRP_NAME}"
BODY="Errore nell' elaborazione dell' ${MRP_NAME} Controllare file ${DISCARDED_FILE_NAME}"
echo "${BODY}"
(echo "$BODY\n";
for file in ${DISCARDED_FILES[@]}
do
uuencode $file `echo $file | cut -d'/' -f9`
done ) | mailx -m -s "${SUBJECT}" ${RECEIVER}
echo mail sent

So I modified accordingly to work in linux sever but failed as shown below :

This code is not working in linux sever:

MRP_NAME=$1
set -A DISCARDED_FILES $2
DISCARDED_FILE_NAME="DISCARDED"
echo "MRP_NAME" ${MRP_NAME}
RECEIVER="xyz@gmail.com"
echo "RECEIVER" ${RECEIVER}
SUBJECT="Error on ${MRP_NAME}"
BODY="Errore nell' elaborazione dell' ${MRP_NAME} Controllare file ${DISCARDED_FILE_NAME}"
echo "${BODY}"
(echo "$BODY\n";
for file in ${DISCARDED_FILES[@]}
do
uuencode $file `echo $file | cut -d'/' -f9`
DISCARDED_FILES+=( "-a" $file)
done ) | mailx "${DISCARDED_FILES[@]}" -s "${SUBJECT}" ${RECEIVER}
echo mail sent

when I ran the above code in linux sever then iam getting below text in mail(body) without any attachments.

Errore nell' elaborazione dell' Controllare file DISCARDED\n
begin 660 shell.txt
3=F%R=6X@:70@:7,@:6X@8F]D>0


end
begin 660 MoneticalBatchExtlogs.txt
M9&-T97)I;#`Q.B]A<'`O<W!E+TUO;F5T:6-A0F%T8VA%>'0O;&]G+T)312,@
M<V@@36]N971I8V%?3&]A9%]$871A7TU24#`Q+G-H"DU24%].04U%.B`M+2TM
M/B!-4E`P,0I-4E!?0TQ!4U-?3D%-13H@+2TM+3X@:70N<V5L;&$N;6]N971I
M8V%B871C:&5X="YA<'`N35)0,#%!<'`*0U123%]&24Q%3D%-13H@+2TM+3X@
M36]N971I8V%?3&]A9%]$871A7TU24#`Q+F-T;`I,3T=?1DE,13H@+2TM+3X@
M+V%P<"]S<&4O36]N971I8V%"871C:$5X="]L;V<O36]N971I8V%?3&]A9%]$
M871A7TU24#`Q7S$Q,#DR,#(P7S$U,#<Q-RYL;V<*6S$U.C`W.C$W72!-;VYE
M=&EC84)A=&-H17AT($U24#`Q('-C<FEP="!S=&%R="XN+@I;,34Z,#<Z,3==
M($UO;F5T:6-A0F%T8VA%>'0@35)0,#$@<V-R:7!T('-T87)T+BXN"ELQ-3HP
M-SHQ-UT@4W1A<G0@9V5N97)A=&EN9R!S97%U96YC92!F;W(@97AC97!T:6]N
M("XN+@I"051#2%]315%514Y#15])1"`](#(Q.#`X"ELQ-3HP-SHQ-UT@16YD
M(&=E;F5R871I;F<@<V5Q=65N8V4@9F]R(&5X8V5P=&EO;B`N+BX*6S$U.C`W
M.C$W72!3=&%R="!I;G-E<G1I;F<@8F%T8V@@9&5T86EL<RXN+@I;,34Z,#<Z


Viewing all articles
Browse latest Browse all 1179

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>