PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > redirection, paste and tee?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

redirection, paste and tee?

Réponse
 
LinkBack Outils de la discussion
Vieux 06/01/2008, 18h48   #1
tmp123
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut redirection, paste and tee?

Hello,

First of all, thanks for your .

After a few hours reading post about redirections, exec, ... I can not
find a final solution to this problem:

Given to programs, "foo" and "bar", the objective is a command who
appends to the result of "foo" the result of "foo | cut -f 4 | bar".
Append in the same way than "paste" does.

That means:

+--> cut --> bar --+
foo -->| +->paste
+-----------------------+

Of course, without temporals ;-)

Probably, I need tee to split the output of "foo" to two streams, but,
how?

Thanks a lot.
  Réponse avec citation
Vieux 06/01/2008, 18h59   #2
tmp123
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: redirection, paste and tee?

On Jan 6, 7:48pm, tmp123 <tmp...@menta.net> wrote:
> Hello,
>
> First of all, thanks for your .
>
> After a few hours reading post about redirections, exec, ... I can not
> find a final solution to this problem:
>
> Given to programs, "foo" and "bar", the objective is a command who
> appends to the result of "foo" the result of "foo | cut -f 4 | bar".
> Append in the same way than "paste" does.
>
> That means:
>
> +--> cut --> bar --+
> foo -->| +->paste
> +-----------------------+
>
> Of course, without temporals ;-)
>
> Probably, I need tee to split the output of "foo" to two streams, but,
> how?
>
> Thanks a lot.


Sorry, I've forgot an small clarification:

The following command produces the expected result:

mkfifo pp
foo | tee pp | cut -f 3 | bar | paste - pp

But an external fifo is need.

Thanks again.
  Réponse avec citation
Vieux 06/01/2008, 19h59   #3
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: redirection, paste and tee?

tmp123 wrote:
> On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote:
>>
>> First of all, thanks for your .
>>
>> After a few hours reading post about redirections, exec, ... I can not
>> find a final solution to this problem:
>>
>> Given to programs, "foo" and "bar", the objective is a command who
>> appends to the result of "foo" the result of "foo | cut -f 4 | bar".
>> Append in the same way than "paste" does.
>>
>> That means:
>>
>> +--> cut --> bar --+
>> foo -->| +->paste
>> +-----------------------+
>>
>> Of course, without temporals ;-)
>>
>> Probably, I need tee to split the output of "foo" to two streams, but,
>> how?
>>
>> Thanks a lot.

>
> Sorry, I've forgot an small clarification:
>
> The following command produces the expected result:
>
> mkfifo pp
> foo | tee pp | cut -f 3 | bar | paste - pp


[GNU bash]


FOO="$(foo)"
echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO")

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
  Réponse avec citation
Vieux 07/01/2008, 11h13   #4
tmp123
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: redirection, paste and tee?

On Jan 6, 8:59 pm, Cyrus Kriticos <cyrus.kriti...@googlemail.com>
wrote:
> tmp123 wrote:
> > On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote:

>
> >> First of all, thanks for your .

>
> >> After a few hours reading post about redirections, exec, ... I can not
> >> find a final solution to this problem:

>
> >> Given to programs, "foo" and "bar", the objective is a command who
> >> appends to the result of "foo" the result of "foo | cut -f 4 | bar".
> >> Append in the same way than "paste" does.

>
> >> That means:

>
> >> +--> cut --> bar --+
> >> foo -->| +->paste
> >> +-----------------------+

>
> >> Of course, without temporals ;-)

>
> >> Probably, I need tee to split the output of "foo" to two streams, but,
> >> how?

>
> >> Thanks a lot.

>
> > Sorry, I've forgot an small clarification:

>
> > The following command produces the expected result:

>
> > mkfifo pp
> > foo | tee pp | cut -f 3 | bar | paste - pp

>
> [GNU bash]
>
> FOO="$(foo)"
> echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO")
>


Hello,

Thanks a lot for your answer.

"foo" is a never ending process. Is the solution valid with this
restriction?

Kind regards.
  Réponse avec citation
Vieux 07/01/2008, 11h24   #5
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: redirection, paste and tee?

tmp123 wrote:
> On Jan 6, 8:59 pm, Cyrus Kriticos <cyrus.kriti...@googlemail.com>
> wrote:
>> tmp123 wrote:
>>> On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote:
>>>> First of all, thanks for your .
>>>> After a few hours reading post about redirections, exec, ... I can not
>>>> find a final solution to this problem:
>>>> Given to programs, "foo" and "bar", the objective is a command who
>>>> appends to the result of "foo" the result of "foo | cut -f 4 | bar".
>>>> Append in the same way than "paste" does.
>>>> That means:
>>>> +--> cut --> bar --+
>>>> foo -->| +->paste
>>>> +-----------------------+
>>>> Of course, without temporals ;-)
>>>> Probably, I need tee to split the output of "foo" to two streams, but,
>>>> how?
>>>> Thanks a lot.
>>> Sorry, I've forgot an small clarification:
>>> The following command produces the expected result:
>>> mkfifo pp
>>> foo | tee pp | cut -f 3 | bar | paste - pp

>> [GNU bash]
>>
>> FOO="$(foo)"
>> echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO")
>>

>
> Hello,
>
> Thanks a lot for your answer.
>
> "foo" is a never ending process. Is the solution valid with this
> restriction?


No.

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
  Réponse avec citation
Vieux 07/01/2008, 14h11   #6
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: redirection, paste and tee?

On Sun, 6 Jan 2008 10:59:31 -0800 (PST), tmp123 wrote:
[...]
>> +--> cut --> bar --+
>> foo -->| +->paste
>> +-----------------------+
>>
>> Of course, without temporals ;-)
>>
>> Probably, I need tee to split the output of "foo" to two streams, but,
>> how?
>>
>> Thanks a lot.

>
> Sorry, I've forgot an small clarification:
>
> The following command produces the expected result:
>
> mkfifo pp
> foo | tee pp | cut -f 3 | bar | paste - pp
>
> But an external fifo is need.

[...]

You can't without a named pipe with usual Unix shells.

You can probably do it in perl on systems with /dev/fd/<n>
though.

$^F = 0xffff;
pipe AR, AW;
pipe BR, BW;
if (fork() == 0) {
open STDOUT, ">&AW";
close AR; close BR; close AW;
exec "foo | tee /dev/fd/" . fileno BW;
}
open STDIN, "<&AR";
close AR; close AW; close BW;
exec "cut -f 3 | bar | paste - /dev/fd/" . fileno BR;

--
Stephane
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h24.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15958 seconds with 14 queries