linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Redirection of STDERR
@ 2004-03-08 10:13 Christoph Pleger
  2004-03-09 16:04 ` Stephen Samuel
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Pleger @ 2004-03-08 10:13 UTC (permalink / raw)
  To: linux-admin, linux-kernel

Hello,

In my initialization scripts for hotplug (written for bash) the
following command is used to redirect output which normally goes to
stderr to the system logger:

"exec 2> >(logger -t $0[$$])"

With kernel 2.4 this command works fine, but with kernel version 2.6.3
it leads to a system hang.

Can anybody help me to solve that problem?

Thanks in advance
  Christoph 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Redirection of STDERR
  2004-03-08 10:13 Redirection of STDERR Christoph Pleger
@ 2004-03-09 16:04 ` Stephen Samuel
  2004-03-09 17:18   ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Samuel @ 2004-03-09 16:04 UTC (permalink / raw)
  To: Christoph Pleger; +Cc: linux-admin, linux-kernel

Christoph Pleger wrote:
> Hello,
> 
> In my initialization scripts for hotplug (written for bash) the
> following command is used to redirect output which normally goes to
> stderr to the system logger:
> 
> "exec 2> >(logger -t $0[$$])"
I don't remember this syntax as legal.
what I'd use would be:
exec some_command 2>&1  | logger -t "$0[$$]"


On the other hand, this could replace the script you're
running with something that may never exit.. (sepending
on what the command does)

> 
> With kernel 2.4 this command works fine, but with kernel version 2.6.3
> it leads to a system hang.

-- 
Stephen Samuel +1(604)876-0426                samuel@bcgreen.com
		   http://www.bcgreen.com/~samuel/
    Powerful committed communication. Transformation touching
      the jewel within each person and bringing it to light.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Redirection of STDERR
  2004-03-09 16:04 ` Stephen Samuel
@ 2004-03-09 17:18   ` Andreas Schwab
  2004-03-10 16:39     ` Stephen Samuel
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-03-09 17:18 UTC (permalink / raw)
  To: Stephen Samuel; +Cc: Christoph Pleger, linux-admin, linux-kernel

Stephen Samuel <samuel@bcgreen.com> writes:

> Christoph Pleger wrote:
>> Hello,
>> In my initialization scripts for hotplug (written for bash) the
>> following command is used to redirect output which normally goes to
>> stderr to the system logger:
>> "exec 2> >(logger -t $0[$$])"
> I don't remember this syntax as legal.

That's the process substitution feature of bash, quite handy when you want
to get an fd connected to a pipe.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Redirection of STDERR
  2004-03-09 17:18   ` Andreas Schwab
@ 2004-03-10 16:39     ` Stephen Samuel
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Samuel @ 2004-03-10 16:39 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Christoph Pleger, linux-admin, linux-kernel

Yeah, you're right.  I was tired when I wrote it,

however, the exec command still isn't quite
complete.  Normally, you'd want a command to be
exec'ing.

In theory, the exec command by itself should (I think) just
redirect for the rest of your commands... However, it would
appear that there's a bug in bash for that syntax.
(i.e. If I type it in on the command line, It doesn't work for me, either).

In this case, I think you're going to be better off to just start
your processes with the output going direct  logger...

my (more successful) way of doing this is:

{
	command 1
	command2
	command3
} | logger -t $0[$$]

(needs a semicolon before the '}' if it's a one-liner.

It's also more portable (compatible with old bourne shells)
I prefer to save things like the named pipe syntax for the really
ornery situations where bourne-compatible syntax jusr doesn't
do the job.

Andreas Schwab wrote:
 > Stephen Samuel <samuel@bcgreen.com> writes:
 >>Christoph Pleger wrote:
 >>>Hello,
 >>>In my initialization scripts for hotplug (written for bash) the
 >>>following command is used to redirect output which normally goes to
 >>>stderr to the system logger:
 >>>"exec 2> >(logger -t $0[$$])"
 >>
 >>I don't remember this syntax as legal.
 >
 > That's the process substitution feature of bash, quite handy when you want
 > to get an fd connected to a pipe.


-- 
Stephen Samuel +1(604)876-0426                samuel@bcgreen.com
		   http://www.bcgreen.com/~samuel/
    Powerful committed communication. Transformation touching
      the jewel within each person and bringing it to light.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-10 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-08 10:13 Redirection of STDERR Christoph Pleger
2004-03-09 16:04 ` Stephen Samuel
2004-03-09 17:18   ` Andreas Schwab
2004-03-10 16:39     ` Stephen Samuel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).