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
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 [email protected]
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.
Stephen Samuel <[email protected]> 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, [email protected]
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."
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.
I found out that the problem exists with bash 2.05b, but not with 2.05a.
The reason is that with 2.05a the command uses the file descriptors
under /dev/fd0 for the pipe, but with 2.05b the command creates a pipe
under /tmp. Obviously, the 2.05b mechanism worked with Kernel 2.4, but
not with 2.6.
Christoph
On Wednesday 10 March 2004 09:50, 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.
>
> I found out that the problem exists with bash 2.05b, but not with 2.05a.
> The reason is that with 2.05a the command uses the file descriptors
> under /dev/fd0 for the pipe, but with 2.05b the command creates a pipe
> under /tmp. Obviously, the 2.05b mechanism worked with Kernel 2.4, but
> not with 2.6.
I always wondered what prevents bash from NOT using
pipes in the filesystem. It does not use them for
ps | less
and friends.
--
vda
Christoph Pleger <[email protected]> writes:
> I found out that the problem exists with bash 2.05b, but not with 2.05a.
> The reason is that with 2.05a the command uses the file descriptors
> under /dev/fd0 for the pipe, but with 2.05b the command creates a pipe
> under /tmp. Obviously, the 2.05b mechanism worked with Kernel 2.4, but
> not with 2.6.
Works fine here, please make sure that your bash isn't misconfigured.
Andreas.
--
Andreas Schwab, SuSE Labs, [email protected]
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."
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 <[email protected]> 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 [email protected]
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.