Operating System - HP-UX
1822707 Members
3601 Online
109644 Solutions
New Discussion юеВ

C-shell, suppressing output of "find: cannot open

 
Bettina Ofner
Advisor

C-shell, suppressing output of "find: cannot open

I have a c-shell with a find command in it.
Is it possible to suppress the output
find: cannot open ... if there is a directory for which the user has no rights.
Error message is confusing users, altought it
is not relevant for the shell (works OK)
Best regards
Bettina
10 REPLIES 10
Lasse Knudsen
Esteemed Contributor

Re: C-shell, suppressing output of "find: cannot open

find "whatever it might be" >& /dev/null
In a world without fences - who needs Gates ?
RikTytgat
Honored Contributor

Re: C-shell, suppressing output of "find: cannot open

Hi,

You can achieve what you want by using following construction:

(program > /dev/tty ) >& stderr_file

stdout will go to the tty, stderr will go to the file stdeerr_file.

Hope this helps,
Rik.
RikTytgat
Honored Contributor

Re: C-shell, suppressing output of "find: cannot open

Hi,

Allan's solution also puts stdout into the file.

Bye,
Rik.
Lasse Knudsen
Esteemed Contributor

Re: C-shell, suppressing output of "find: cannot open

Yeah I saw that - sorry.
In a world without fences - who needs Gates ?
Bettina Ofner
Advisor

Re: C-shell, suppressing output of "find: cannot open

Need to use the find information
construction is
set liste = `find ....`
If I use >dev/tty liste is empty
Dan Hetzel
Honored Contributor

Re: C-shell, suppressing output of "find: cannot open

Hi,

This example should do the trick:

set liste=`find /etc -name "*.conf" |& grep -v "^find:"`

|& redirects stderr with stdout, in this case into the pipe

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Rainer_1
Honored Contributor

Re: C-shell, suppressing output of "find: cannot open

redirect stderr in posix-sh is easier.
set liste=`/sbin/sh -c "find ... 2>/dev/null"`
Stefan Schulz
Honored Contributor

Re: C-shell, suppressing output of "find: cannot open

AFAIK there is a set command which should supress such error messages.

think it is:

set nonomatch

Perhaps setting this in your script befor the find command it supresses this messages.

don't know if this works.
No Mouse found. System halted. Press Mousebutton to continue.
Maureen Gunkel
Trusted Contributor

Re: C-shell, suppressing output of "find: cannot open

When running the find command, I use the following to suppress just the error messages:

find 2>/dev/null

the 2 says errors only
>/dev/null says output to the null device.

Hope this helps.
No matter where you go, there you are.
Maureen Gunkel
Trusted Contributor

Re: C-shell, suppressing output of "find: cannot open

When running the find command, I use the following to suppress just the error messages:

find 2>/dev/null

the 2 says errors only
>/dev/null says output to the null device.

Hope this helps.
No matter where you go, there you are.