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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

catch stderr from a piped input of a script

Status
Not open for further replies.

OieL

MIS
Sep 6, 2002
17
0
0
US
Hi
i am doing a script that gets input from a pipe (ie. from find) and it should be running like this .
$ find . -type f | script

>>START TRUE OUTPUT HERE<<<
file1 processed
find: ./etc/news/teset: Permission denied
file2 processed
file3 processed
file4 processed
find: ./etc/news/file5: Permission denied
file5 processed
:
:
but I am getting an output like this

$ find . -type f | script

find: ./etc/news/teset: Permission denied
find: ./etc/news/2/4: Permission denied
find: ./etc/news/3: Permission denied

>>START TRUE OUTPUT HERE<<<
file1 processed
file2 processed
file3 processed
file4 processed
file5 processed
:
:
It seems that stderr comes out first... what will I do with this kind of scenario ... Inside my script I have a while loop that reads from the pipe input ... any help ?

thanks
 
try:
your-script 'find . 2>/dev/null'
' is a backquote
or
find . 2>/dev/null | your-script -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
I can't use that because that's the requirement .. any more ideas how to catch stderr in

find . -type f | script

thnks


 
Very similar to jamisar

find . 2>&1 | your-script Mike

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top