Hazimil
Contributor
- Joined
- May 26, 2014
- Messages
- 172
Hi All
Would appreciate some community feedback here. I have written (and shared) a few scripts for my FreeNAS server which the enduser needs to edit to update their email address, and I was looking at how I could remove this step, to make the scripts even easier to use.
I'm not sure about everyone else, but I send all reports (and script outputs) from my FreeNAS box to the email address used by root, and this email address is store in the file /etc/aliases. I have written the following snippet of code to extract the email address assigned to root:
Basically the code:
Yours
Jonathan
Would appreciate some community feedback here. I have written (and shared) a few scripts for my FreeNAS server which the enduser needs to edit to update their email address, and I was looking at how I could remove this step, to make the scripts even easier to use.
I'm not sure about everyone else, but I send all reports (and script outputs) from my FreeNAS box to the email address used by root, and this email address is store in the file /etc/aliases. I have written the following snippet of code to extract the email address assigned to root:
Code:
grep -v '#' /etc/aliases | grep root: | cut -c 7-
Basically the code:
- strip all lines with a # (i.e. comments)
- looks for the line starting root:
- cut the first 6 characters from that line
- leaving an email address
Yours
Jonathan