My script almost works but spams the terminal its launched from if useing dash.
Greetings;
This bash script has lived in ~/bin for years, but the mention of dash as
a replacement for bash made me want to test it with dash by changing the
bang line to #!/bin/sh, which is of course (this is wheezy) a softlink
to /bin/dash.
I am launching it with this command as I don't want it to make any noise
at all when its running, just do its job:
bin/mailwatcher 2>&1 >/dev/null &
But when I run it with dash, it doesn't seem to work right, and spams the
terminal with its error messages. One that appears to kill its function
is the bashism of using [[ ]] to surround string variables, reported
like this:
bin/mailwatcher: 64: bin/mailwatcher: [[: not found
bin/mailwatcher: 70: bin/mailwatcher: [[: not found
bin/mailwatcher: 77: bin/mailwatcher: [[: not found
Which is nice, as I am seeing the reason it fails. Line 64 to illuminate
that is:
if [[ ${InMail} = 'gene' ]]
The other 2 lines are similar except for 'gene'
The return from inotifywait is what sets the value of ${InMail}
Can these lines be re-constructed to be valid for either bash or dash?
If so how?
And finally, once its working with either shell, how do I shut it up
totally? Even the above command line launch fails as it outputs to that
shell, a newline for every incoming mail which gradually scrolls any
output that was on-screen, offscreen without leaving a prompt until I
tap the return key to restore it.
Thank you for any insight on this.
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
Reply to: