![](/img/trans.png)
[英]Need to send a mail (bash or php script) using “sendmail” of a different linux server
[英]Linux: sendmail in a bash script
如果文件包含1000行以上,我需要通过邮件发送文件名,文件的时间戳及其行数。
ll -h在我的脚本中不起作用(抛出错误并且发送的邮件为空白),尽管它作为单独的命令运行。
无法运作:
#!/bin/sh
pfad="/home/bspftp/script"
rows=1000
actualsize=$(wc -l <"$1")
if [ $actualsize -ge $rows ]; then
echo "In the file $1 there are more than $rows rows"
ll -h $pfad/$1 | sendmail my@mail.net #throws error: line 7: ll: command not found
else
echo "In the file $1 there are less than $rows rows"
fi
我执行脚本如下:
bash num_rows.sh ~/script/file.log
工作:
ll -h ~/script/file.log | sendmail my@mail.net
您必须使用全路径ll
或将其添加到您的环境PATH
变量中。
您可以使用whereis ll
在哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.