gpt4 book ai didi

Linux : mail send file content as mail content

转载 作者:太空宇宙 更新时间:2023-11-04 03:43:38 29 4
gpt4 key购买 nike

我创建了一个.sh脚本,并将结果记录在一个文件中,执行后我会尝试将文件内容作为mail正文发送。

这是我运行的命令:

sh update.sh >> update.$(date +"%Y-%m-%d:%H").txt 2>&1 && mail -s "Integration : import du $(date +%Y-%m-%d) a $(date +%H)h" sample@example.com < update.$(date +"%Y-%m-%d:%H").txt 

这样好吗?

这是update.sh的代码:

#!/bin/ksh
. /root/.bash_profile

red='\033[0;31m'
green='\033[0;32m'
yellow='\033[1;33m'
blue='\033[0;34m'
purple='\033[0;35m'
NC='\033[0m' # No Color
DATE=$(date +%d-%m-%Y\ %H:%M:%S)
quiet=
composer=

echo " "
echo -e " ${green}[${DATE}]${purple} Mise a jour de dalia${NC}"
echo " "

function update_composer {
if [ "$composer" == 1 ]; then
echo " "
echo -e " ${yellow}Mise a jour de composer (des vendors)${NC}"
if [ "$quiet" == 1 ]; then
composer update --prefer-dist -q
else
composer update --prefer-dist
fi
echo " "
fi
}

function update_db {
echo " "
echo -e " ${yellow}Mise a jour de la base de donnee${NC}"
if [ "$quiet" == 1 ]; then
php app/console doctrine:schema:update --force -q
else
php app/console doctrine:schema:update --force
fi
echo " "
}

function update_svn {
echo " "
echo -e " ${yellow}Mise a jour depuis svn${NC}"
if [ "$quiet" == 1 ]; then
svn update -q
else
svn update
fi
echo " "
}

function install_assets {
echo " "
echo -e " ${yellow}Installation des assets${NC}"
if [ "$quiet" == 1 ]; then
php app/console assets:install --env=prod -q && php app/console assetic:dump --env=prod -q
else
php app/console assets:install --env=prod && php app/console assetic:dump --env=prod
fi
echo " "
}

function cache_clear {
echo " "
echo -e " ${yellow}Effacement du cache de prod${NC}"
if [ "$quiet" == 1 ]; then
php app/console cache:clear --env=prod -q
else
php app/console cache:clear --env=prod
fi
echo " "
}

while [ "$1" != "" ]; do
case $1 in
-q | --quiet ) quiet=1
;;
-c | --composer ) composer=1
;;
esac
shift
done

while [ "$2" != "" ]; do
case $2 in
-q | --quiet ) quiet=1
;;
-c | --composer ) composer=1
;;
esac
shift
done

update_svn
update_composer
update_db
cache_clear
install_assets
cache_clear

echo " "
echo -e " ${blue}Changement des permissions${NC}"
chmod 777 -R * && chown apache:apache -R *
echo " "

echo -e " ${green}Fait${NC}"

echo " "

最佳答案

Terminal color codes don't work in email as such

就是这样,我删除了所有颜色,并将所有 echo -e 替换为 echo,邮件内容很好。

关于Linux : mail send file content as mail content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28938272/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com