简体   繁体   中英

if statement unix shell script

I am using if statement to check for a condition and assign values. A mail will be sent after that. I executing the script ( bash ) but nothing really happens and I have to exit; could anyone tell me what I am doing wrong?

if [ $var -eq 0 ]
then
subject="there are zero issues"
else
subject="there are issues"
fi

mail -s "$subject" abc@gmail.com

The Unix mail command is waiting to receive a message body to send, but you have not provided one in your script. Try this:

$ mail -s "$subject" abc@gmail.com < /home/user/yourmessage.txt

where /home/user/yourmessage.txt contains some message you wish to include in the email.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM