[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: My script almost works but spams the terminal its launched from if useing dash.



On Sunday 17 April 2016 02:25:01 Michael Milliman wrote:

> On 04/16/2016 12:11 PM, Aero Maxx wrote:
> > On 16/04/2016 17:45, Gene Heskett wrote:
> >> On Saturday 16 April 2016 12:01:28 Aero Maxx wrote:
> >>> On 16/04/2016 16:23, Gene Heskett wrote:
> >>>> 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
> >>>
> >>> dash isn't the same as bash, as it has a limited set of
> >>> instructions or commands it can do.
> >>>
> >>> But I too would be interested to know if it is possible to get it
> >>> to work in dash, I don't believe it is, but I am happy to be
> >>> corrected or proved wrong.
> >>>
> >>>> 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.
> >>>
> >>> Also isn't the command you are running supposed to be as follows ?
> >>>
> >>>> bin/mailwatcher 2>&1 > /dev/null &
> >>
> >> Is the space you inserted into my line between the > and the
> >> /dev/null a game changer? In either bash or dash?  Its been a while
> >> since I last read the bash docs, but I don't recall there was any
> >> emphasis on that.
> >
> > I'm sorry I was a bit too eager to reply and neglected to change
> > what I had pasted in.
> >
> > I meant to say could you try this
> >
> >> bin/mailwatcher > /dev/null 2>&1 &
>
> Yes, this is the correct incantation.  The difference is very subtle.

And not very well noted in the bash .pdf or the man page.

> With ... 2>&1 >/dev/null, the error output is redirected to be the
> same as the standard output, and then the standard output is
> redirected to /dev/null -- leaving the error output still going to the
> original standard output (terminal).  With ... >/dev/null 2>&1 The
> standard output is redirected first, and the the error output is sent
> to the same place as the standard output, resulting in both going to
> /dev/null.  The order of redirection is important to the end results
> in this case.

Good to know, and thank you.

> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus


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: