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 > unix command > file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

unix command > file

Réponse
 
LinkBack Outils de la discussion
Vieux 07/11/2006, 23h50   #1
YAB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut unix command > file

Hi,
It is a newbie general question. I want to redirect the result of bdf (or
df -k) in a
file.

I tried this.
[%] echo $SHELL
ksh
[%] bdf > toto ; bdf | tee toto ; bdf 2>toto

My Pb is that size of toto is always 0
Why ? How to redirect bdf output into toto file ?
Thanks



  Réponse avec citation
Vieux 08/11/2006, 00h55   #2
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: unix command > file

On 2006-11-07, YAB wrote:
> Hi,
> It is a newbie general question. I want to redirect the result of bdf (or
> df -k) in a
> file.
>
> I tried this.
> [%] echo $SHELL
> ksh
> [%] bdf > toto ; bdf | tee toto ; bdf 2>toto
>
> My Pb is that size of toto is always 0
> Why ? How to redirect bdf output into toto file ?


All of those should work. What is the output of bdf without any
redirection?

Post the output of:

bdf | tee toto
ls -l toto

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 08/11/2006, 05h11   #3
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: unix command > file

On Wed, 8 Nov 2006 00:50:41 +0100, YAB
<yhab.abiad@orange.fr> wrote:
> Hi,
> It is a newbie general question. I want to redirect the result of bdf (or
> df -k) in a
> file.
>
> I tried this.
> [%] echo $SHELL
> ksh
> [%] bdf > toto ; bdf | tee toto ; bdf 2>toto
>

Each command erases the previous content of toto. Try using >> instead
of >, and "tee -a". Or you could use
bdf > toto 2>&1


--
meterologist, n.:
One who doubts the established fact that it is
bound to rain if you forget your umbrella.
  Réponse avec citation
Vieux 09/11/2006, 19h42   #4
YAB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: unix command > file

Of course, I've executed commands seperatly and after each command I've run
ls -l
bdf => gives a correct standard output
bdf > toto => then ls -l toto prints 0 length for toto
and so on for other commands (bdf | tee toto).

All your answers confirm that there is no syntax error with my command.
I'll try with bdf >> toto and with bdf | tee -a toto
I'll check also if there is a quota limit with my account.

Many thanks for your answers.

"Bill Marcum" <bmarcum@iglou.com> a écrit dans le message de
news:3h5824-989.ln1@don.localnet...
> On Wed, 8 Nov 2006 00:50:41 +0100, YAB
> <yhab.abiad@orange.fr> wrote:
> > Hi,
> > It is a newbie general question. I want to redirect the result of bdf

(or
> > df -k) in a
> > file.
> >
> > I tried this.
> > [%] echo $SHELL
> > ksh
> > [%] bdf > toto ; bdf | tee toto ; bdf 2>toto
> >

> Each command erases the previous content of toto. Try using >> instead
> of >, and "tee -a". Or you could use
> bdf > toto 2>&1
>
>
> --
> meterologist, n.:
> One who doubts the established fact that it is
> bound to rain if you forget your umbrella.



  Réponse avec citation
Vieux 10/11/2006, 00h15   #5
dt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: unix command > file

YAB wrote:

> Hi,
> It is a newbie general question. I want to redirect the result of bdf (or
> df -k) in a
> file.
>
> I tried this.
> [%] echo $SHELL
> ksh
> [%] bdf > toto ; bdf | tee toto ; bdf 2>toto

^^^^^^^^^^
this last command is the only one that matters
it must be that the bdf command produces no output on stderr

> My Pb is that size of toto is always 0
> Why ?


the shell is redirecting stderr output from bdf to file toto

we know that toto is overwritten before bdf is executed (the
techincal term is truncated) which is just a natural consequence
of how shell redirection works

but since bdf produces no output on stderr, nothing is ever
written to toto, thus toto remains at 0 bytes

> How to redirect bdf output into toto file ?


bdf > toto # overwrite contents of toto
bdf >> toto # append to contents to toto


--
Posted via a free Usenet account from http://www.teranews.com

  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 08h20.


Édité par : vBulletin® version 3.7.3
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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12424 seconds with 13 queries