Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting: No command output on screen

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

again I'm trying to write a nice little script and again I've been encountering some problems.

Here are the facts:

I have an array with 10 values called MOJB.
I have a little tool called "scsitest" that requires 10 input values when run.
I don't want the output of my script to appear on the screen.

Now the problem is with the following line:

print ${MOJB[*]} | scsitest | grep "Jukebox"

I get the whole output on the screen ...

If I change it like this:

print ${MOJB[*]} | scsitest | grep "Jukebox" > /dev/null

it only affects the grep output and I still get the scsitest output on the screen.

If I change it like this:

print ${MOJB[*]} | scsitest 2&> | grep "Jukebox"

it perfectly suppresses the output of scsitest, but the grep does not get anything to grep anymore ...

How can I solve this problem ?

Thanks in advance !

Regards
Thomas
 
It looks like you need to supress stderr from scsitest. Try

Code:
print ${MOJB[*]} | scsitest 2>/dev/null | grep Jukebox

Ceci n'est pas une signature
Columb Healy
 
Hi

If you want to suppress output from script, try this:

# Header

exec 1>/dev/null
exec 2>/dev/null

#Script code goes here

exec 1>&-
exec 2>&-

This will redirect output from stdout (1) and stderr (2) to /dev/null for all commands in the script.

It's a neat way of writing info to a log file and keeping errors in a separate file. BTW, some commands actually produce useful output on stderr. Why? Who knows :)

HTH


Kind Regards,
Matthew Bourne
"Find a job you love and never do a day's work in your life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top