Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hello I am creating a simple mail script (just got into the world of scripting) My goal is to pretty much test if it has been sent out successful. I know I can just check my email, but is there a way to tell the bash script
(logical thinking)
if
"mail has been sent"
echo success!
else
echo did not process
fi
this is my script now
#!/bin/bash
echo "mail is being sent"
echo "...."
echo "...."
echo "...."
echo "...."
echo "...."
mpack -s hello /disk/windex/users/wchaple/testsample.txt sample@yahoo.com
echo "...."
echo "...."
echo "...."
echo "...."
echo "...."
echo "mail has been sent out succesfully"
MPack is a PHP-based malware kit produced by Russian crackers, so I don't recommend you use that
Per the LQ Rules: "Posts containing information about cracking, piracy, warez, fraud or any topic that could be damaging to either LinuxQuestions.org or any third party will be immediately removed.", and this one seems close. Therefore reported and we'll let a moderator determine that
Check my link for My Bash Blog (see my signature) and there are tips for BASH scripting, one of them is the option to check the return from a system call to evaluate the result.
The OP seems to be new to Linux, noting that they've said they're new to scripting, and perhaps they found the first thing which worked and also perhaps the program, while having nefarious origins may also have test and/or reasonable use cases. Hence why I said let's allow a moderator to make that judgment. I know there are other ways to generate mail from the command line, such as "sendmail" or just "mail".
echo "message" | mail -s "subject" user@domain.com
if [[ $? -eq 0 ]]; then
echo "Message sent successfully"
else
echo "Error sending message"
fi
Note that the exit status only tells you whether or not mail was able to submit the message, it says nothing about whether it was actually delivered. A LOT of ISPs block outgoing mail on port 25 for residential customers to cut down on spam, mail's exit status won't tell you if your ISP blocked your message or not.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.