Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Regarding export EMAIL
this statement exports EMAIL variable from the current process to some "global" level, so this variable may be used by child processes.
the last echo $a output will be empty because $a not initialized for the child bash process.
However, if we will set it (export) in global scope, we can use it in child process:
As for concatenation: it isn't ordinary concatenation. "&&" means that the following command will be executed only if previous command exited successfully. Otherwise following command will not be launched
1. export assigns "ABC <abc@example.com>" string to EMAIL variable. This variable will be available for /usr/bin/mutt since it is a child process of your terminal process. I'm not aware of will mutt really use this variable or not, but it will be available for mutt.
2. Of course you can put this string:
/usr/bin/mutt -s "Test subject” -a <attachment> abc@example.com <”Test content”
in the script and run it (don't forget to make script executable).
Will it send email? Do not know. Why wouldn't you test it yourself? I have no mutt installed, so I can't check it. Just replace abc@example.com with real email address and try to send.
There is a command in one of the script being used in our system (values changed) which is like:
export EMAIL="ABC <abc@example.com>" && /usr/bin/mutt -s "Test subject” -a <attachment> abc@example.com <”Test content”
In the above statement, I am not able to understand below points:
1) export EMAIL
2) How does concatenation like EMAIL="ABC <abc@example.com>" && /usr/bin/mutt work. I understand what mutt -s "Test subject” -a <attachment> abc@example.com <”Test content” means, but am not able to understand how the concatenation works.
3) Is a mail going to be sent with the above command?
I hope my question is clear of not understanding above 3 points.
Out of that many hits, were you not able to find answers? Again, it's odd that someone with an 'RHCE certification', would not know answers to very basic things like this. While they may not have been covered extensively on the exam, any administrator with even a small amount of experience should be familiar with these things.
The && and || operators also find use in an arithmetic context without explaining how || works. I been trying to get a good explanation but have not got it.
We can only give you an explanation...we can't make you understand it. That link tells you EXACTLY what those operators do, and how they function, with examples. If you clicked on that link, and read ANYTHING around where it took you, you'd see the "||" is an OR operator, and the "&&" is AND. It even has examples on how they're used. Soderlund gave you an explanation, but you really need to read documentation, and start thinking about and applying the knowledge you're given.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.