TOSS_OUTPUT=' >/dev/null' doesn't work

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by kj » Mon, 24 May 2004 05:18:44



I want to do something like this in a bash script:

  if [[ $VERBOSE ]]; then
    TOSS_OUTPUT=''
  else
    TOSS_OUTPUT=' >/dev/null'
  fi

  windbag $TOSS_OUTPUT

...except it doesn't work.  What actually gets executed is

  windbag ' >/dev/null'

Is there any way to do what I want to do?  (Needless to say, windbag
does not have a --quiet option.)

Thanks!

kj

--
NOTE: In my address everything before the period is backwards.

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Chris F.A. Johnso » Mon, 24 May 2004 05:32:22



> I want to do something like this in a bash script:

>   if [[ $VERBOSE ]]; then
>     TOSS_OUTPUT=''
>   else
>     TOSS_OUTPUT=' >/dev/null'
>   fi

>   windbag $TOSS_OUTPUT

> ...except it doesn't work.  What actually gets executed is

>   windbag ' >/dev/null'

> Is there any way to do what I want to do?  (Needless to say, windbag
> does not have a --quiet option.)

[ $VERBOSE -gt 0 ] && windbag || windbag >/dev/null

   Or:

[ $VERBOSE -gt 0 ] && out=/dev/fd/1 || out=/dev/null
windbag > $out

--
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Edward Lloyd Hillm » Mon, 24 May 2004 06:18:17




Quote:

> I want to do something like this in a bash script:

>   if [[ $VERBOSE ]]; then
>     TOSS_OUTPUT=''
>   else
>     TOSS_OUTPUT=' >/dev/null'
>   fi

>   windbag $TOSS_OUTPUT

> ...except it doesn't work.  What actually gets executed is

>   windbag ' >/dev/null'

> Is there any way to do what I want to do?  (Needless to say, windbag
> does not have a --quiet option.)

> Thanks!

> kj

Try using double quotes (") in place of tics ('); i.e.,
   if [[ $VERBOSE ]]; then
     TOSS_OUTPUT=""
   else
     TOSS_OUTPUT=" >/dev/null"
   fi

--
Ed. Hillman
Signature?!?  I don't need no stinking signature!!

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Barry Margoli » Mon, 24 May 2004 06:22:25




Quote:> I want to do something like this in a bash script:

>   if [[ $VERBOSE ]]; then
>     TOSS_OUTPUT=''
>   else
>     TOSS_OUTPUT=' >/dev/null'
>   fi

>   windbag $TOSS_OUTPUT

> ...except it doesn't work.  What actually gets executed is

>   windbag ' >/dev/null'

> Is there any way to do what I want to do?  (Needless to say, windbag
> does not have a --quiet option.)

eval windbag $TOSS_OUTPUT

or:

exec 3>&1
if [[ $VERBOSE ]]
then :
else exec >/dev/null
fi
windbag
exec 1>&3 3>&-

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Barry Margoli » Mon, 24 May 2004 09:35:38






> > I want to do something like this in a bash script:

> >   if [[ $VERBOSE ]]; then
> >     TOSS_OUTPUT=''
> >   else
> >     TOSS_OUTPUT=' >/dev/null'
> >   fi

> >   windbag $TOSS_OUTPUT

> > ...except it doesn't work.  What actually gets executed is

> >   windbag ' >/dev/null'

> > Is there any way to do what I want to do?  (Needless to say, windbag
> > does not have a --quiet option.)

> > Thanks!

> > kj

> Try using double quotes (") in place of tics ('); i.e.,
>    if [[ $VERBOSE ]]; then
>      TOSS_OUTPUT=""
>    else
>      TOSS_OUTPUT=" >/dev/null"
>    fi

Why?  The only difference between them is whether variables and
backticks are expanded inside the quotes.  Since the string contains
neither, both assignments are equivalent.

The choice of quoting at assignment time certainly has no effect on how
the string will be interpreted when it's expanded later.

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Kevin Rodger » Wed, 26 May 2004 04:47:22


 > [ $VERBOSE -gt 0 ] && windbag || windbag >/dev/null

If VERBOSE is greater than zero but the windbag program returns non-zero
for any reason, it will be run a second time with its output redirected
to /dev/null.

 >    Or:
 >
 > [ $VERBOSE -gt 0 ] && out=/dev/fd/1 || out=/dev/null
 > windbag > $out

--
Kevin Rodgers

 
 
 

TOSS_OUTPUT=' >/dev/null' doesn't work

Post by Villy Krus » Wed, 26 May 2004 23:05:02


On Mon, 24 May 2004 13:47:22 -0600,


> > [ $VERBOSE -gt 0 ] && windbag || windbag >/dev/null

> If VERBOSE is greater than zero but the windbag program returns non-zero
> for any reason, it will be run a second time with its output redirected
> to /dev/null.

as if there were anything wrong with good old if ...; then ...; else ...; fi

Villy

 
 
 

1. rsh machine -n 'command >&/dev/null </dev/null &'

My copy of the Unix FAQ suggests syntax like this

            rsh machine -n 'command >&/dev/null </dev/null &'

for running rsh (assuming I use csh on the remote machine, and
something similar if I use sh remotely).  This has always worked
fine for me under SunOS 4.1.2.

My question is: Will this magic necessary under Solaris 2.X?

Many thanks!
---
------------------------------------------------------------------
Francois-Michel Lang          (202) 752-6067   FAX: (202) 752-5074


2. 2.5.36: PCI: Unable to reserve I/O region

3. Even 'cat file >/dev/lp0' doesn't work

4. kfm -sw overloads system!

5. Why does SunOS crash for '(cmd &) >& /dev/null'?

6. Driver ifnet for the management of two ethernet adapter

7. Issuing 'echo <ESC>[r' from .cshrc doesn't work, HELP

8. synchronization problem

9. ksh ': >a >b' -vs- '>a >b' re speed

10. HELP: 2>&1 > /dev/null != 2>&- > /dev/null ???

11. ping -g 'gateway-IP' 'host-IP' DOESN'T work!

12. 'ppp-on' Works, 'ifup ppp0' Doesn't

13. Re. bffcreate -X doesn't work Re: bffcreate -X Doesn't Work