Likely there are bundles of ways of doing the same thing, but they all boil down to the same thing: checking if a condition is true, and acting accordingly.
The method I showed just executes the script (the ``
marks are called backticks
, and they mean 'execute this stuff in a separate shell
') and then uses the >
(called a shell redirect
) to direct ANY output from the script, into the motd. The reason I did it this way is because: the fact that a script executed to completion does NOT necessarily mean that the desired outcome was achieved. This is because BASH does not under normal circumstances quit executing if an error occurs, rather it spits out an error and keeps on plowing along. So doing that my way makes all
output, good or bad, end up in the motd; your motd would then contain the substance of any errors that occurred..
Another way, comparable to yours there in post#3, is to execute the script in ["brackets"] as a conditional argument and act on the result, like:
[ "`/path/to/script`" ] && echo "Success" > motd || echo "Failure" > motd
so this example, if the script terminates with a 0 status, print 'success', otherwise print 'failure'.
In this case, the [
means IF TRUE
and the &&
and the ||
Again, there are LOTS of ways to accomplish this, and I don't probably know even a fraction of them!
As for what page to read in what tutorial, I cannot point you there, but Googling for bash tutorials and the Advanced Bash Guide as you have are good steps in the right direction. However, don't forget 'man bash'!! The bash man page is very comprehensive indeed!
PS - VERY cool that you are in Halifax
you are the first person I have ever seen on here in N.S. One other was in N.B. but that's the closest to me that I have seen to date before you.
I wasn't aware there even *was* a NSLUG despite searching on and off online for one. I may well go sometime though, that would be grand! How are the meetings?? The last UG I was in was a LOOOONG time ago-- it was the NSCCUG. In case you aren't familiar, that was the 'Nova Scotia Commodore Computer Users Group'!! LOL
I'll update my email address on my profile so perhaps you could give me a link or details about the NSLUG. EDIT: Isn't there a forum area here for LUGs? I'll check there too.
I'm from Halifax but moved to Stewiacke (the sticks) a couple years ago.