I am using mailx command with -E flag.This is what it says in man page for linux.
-E If an outgoing message does not contain any text in its first or
only message part, do not send it but discard it silently,
effectively setting the skipemptybody variable at program
startup. This is useful for sending messages from scripts
started by cron(8)
.How ever i cannot use -E flag on AIX servers.any idea ? or is there any substitute i can you use?this is the script`
#!/usr/bin/env bash
shopt -s nullglob #to make `("$src_dir"*.300)` works
src_dir="/exports/files/" #don't forget trailing slash /
dest_dir="/exports/files/arch/" #don't forget trailing slash /
err_f="/tmp/error.txt"
mv_f="/tmp/moved.log" #record moved file in case network down
email="support@abc.com"
touch "$err_f" #bcoz we use >> apppend
touch "$mv_f" #bcoz we use tee -a append
if [ ! -d "$src_dir" ]; then echo|mailx -s "Error: directory $src_dir not exist" "$email" 2>>"$err_f"; exit 1; fi
if [ ! -d "$dest_dir" ]; then echo|mailx -s "Error: directory $dest_dir not exist" "$email" 2>>"$err_f"; exit 1; fi
{
f=("$src_dir"*.300)
for ((i=0; i < ${#f[@]}; i+=1)); do
mv -f "${f[i]}" "$dest_dir" 2>>"$err_f"; #-f do not prompt
if [ $? -eq 0 ]; then
if [ "$i" -eq 0 ]; then echo "$(date +"%Y-%m-%d %H:%M:%S")"; echo "The following files has been moved from $src_dir to $dest_dir"; echo; fi
echo "$((i+1))." "$(basename "${f[i]}")" 'moved'; echo;
else
echo| mailx -s "Error: $(<"$err_f")" "$email" 2>>"$err_f"; break
fi
done
} | tee -a "$mv_f" | mailx -E -s "The following files has been moved" "$email" 2>>"$err_f"
is ther any way i can remove -E flag if i do remove it sends null message when there is no text.I want to supress it.Somehow -E flag doesnot work on the my servers