How to hide the output from echo "select..."|dbaccess sysmaster?
Posted in 1999
Topics: Stored Procedures & SPL, Server Administration
Hi all,
I'm trying to hide some output displayed from the unix command below for
example:
echo "select name from sysdatabase"|dbaccess sysmaster|grep eagle
Open database... <--------- would like to hide
eagle
22 row(s) .... <--------- would like to hide
Close database.. <--------- would like to hide
I tried to redirect the output to /dev/null 2>&1 but not successful.
Thank you in advance for any idea.
H.V
Huy Vu wrote:
> Hi all,
>
> I'm trying to hide some output displayed from the unix command below for
> example:
>
> echo "select name from sysdatabase"|dbaccess sysmaster|grep eagle
>
> Open database... <--------- would like to hide
>
> eagle
>
> 22 row(s) .... <--------- would like to hide
>
> Close database.. <--------- would like to hide
>
> I tried to redirect the output to /dev/null 2>&1 but not successful.
>
> Thank you in advance for any idea.
>
> H.V
redirect stderr to /dev/null. like this
echo "select name from sysdatabase"|dbaccess sysmaster 2>/dev/null |grep
eagle
Thanks again all of you.
It's very helpful your suggestions. I know how to do it now.
H.V
Huy Vu <huyv@usa.net> wrote in message
news:E6YO2.75711$Mb.30683722@newscontent-02.sprint.ca...
> Hi all,
>
> I'm trying to hide some output displayed from the unix command below for
> example:
>
> echo "select name from sysdatabase"|dbaccess sysmaster|grep eagle
>
> Open database... <--------- would like to hide
>
> eagle
>
> 22 row(s) .... <--------- would like to hide
>
> Close database.. <--------- would like to hide
>
> I tried to redirect the output to /dev/null 2>&1 but not successful.
>
> Thank you in advance for any idea.
>
> H.V
>
>
You are on the right track, maybe try redirecting sterr to null instead.
Some programs use sterr (Standard Error) as it's output. Just 2>&1 does
not necessarily go to null try "2>&1 > /dev/null". My suggestion would
be to simplify as much at first to test where the output is comming
from. For instance just try 2>/dev/null or 1>/dev/null and see which, if
not both, need to be redirected.
Huy Vu wrote:
>
> Hi all,
>
> I'm trying to hide some output displayed from the unix command below for
> example:
>
> echo "select name from sysdatabase"|dbaccess sysmaster|grep eagle
>
> Open database... <--------- would like to hide
>
> eagle
>
> 22 row(s) .... <--------- would like to hide
>
> Close database.. <--------- would like to hide
>
> I tried to redirect the output to /dev/null 2>&1 but not successful.
>
> Thank you in advance for any idea.
>
> H.V
A slightly different suggestion than the others is possibly more
flexible for future requirements. The idea is to get your output to a
file (named uniquely each time you run your select) and then you can use
any kind of Unix tools (sed,awk,cut,grep etc. to process it).
Something like
dbaccess << !! >/tmp/tmpfile.$$ >2/dev/null
database stores;
select name from sysdatabase;!!
grep eagle /tmp/tmpfile.$$
rm /tmp/tmpfile.$$
Note the .$$ puts the process id of this job on the end of the filename
so it would always be unique. Using this techinique you can do many more
manipulations with the returned data, but at a slightly higher resource
cost. Note the dbaccess syntax may be slightly different (I forget) -
maybe dbacess -iq < !! >/tmp/tmpfile.$$.
PR
Huy Vu wrote:
>
> Hi all,
>
> I'm trying to hide some output displayed from the unix command below for
> example:
>
> echo "select name from sysdatabase"|dbaccess sysmaster|grep eagle
>
> Open database... <--------- would like to hide
>
> eagle
>
> 22 row(s) .... <--------- would like to hide
>
> Close database.. <--------- would like to hide
>
> I tried to redirect the output to /dev/null 2>&1 but not successful.
>
> Thank you in advance for any idea.
>
> H.V
[courtesy cc of this posting sent to cited author via email] In comp.unix.shell, Paul Redman <paulredman@home.com> writes: :Note the .$$ puts the process id of this job on the end of the filename :so it would always be unique. I wouldn't worry about it much, but technically speaking, that's not true. Most importantly, the system will recylce process IDs once they wrap. There's also the issue of NFS. --tom -- Pretty printers mechanically produce pretty output that accentuates irrelevant detail in the program, which is as sensible as putting all the prepositions in English text in bold font. --Rob Pike