• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

Scripte Ausgabeumleitung

carsto

Hacker
Hallo,

habe folgendes Script welches läuft, aber seine Ausgaben nicht wie gewollt in eine Datei schreibt, sondern nur auf den Bildschirm, warum sowas ??

#!/bin/bash
cd /
rm /tt/backup/* >/tt/backup.log
...
rcmysql start >/tt/mirror.log
dd if=/dev/hda of=/dev/hdc bs=32768 >>/tt/mirror.log
rcmysql stop >>/tt/mirror.log

cu Carsten.
 

taki

Advanced Hacker
Hallo Carsten.
carsto schrieb:
Hallo,
...
rm /tt/backup/* >/tt/backup.log
...

Mit > geht die Standardausgabe in die Datei.
Du willst die Fehlerausgabe und die Standardausgabe in der Datei sehen.

Versuchs mal mit

Code:
...
rm /tt/backup/* >  /tt/backup.log 2>&1


Gefunden mit
Code:
man bash
...
REDIRECTION
     Before a command is executed, its input and  output  may  be
     redirected  using  a  special  notation  interpreted  by the
     shell.  Redirection may also be used to open and close files
     for  the current shell execution environment.  The following
     redirection operators may precede or appear anywhere  within
     a  simple command or may follow a command.  Redirections are
     processed in the order they appear, from left to right. 

     In the following descriptions, if the file descriptor number
     is  omitted,  and  the  first  character  of the redirection
     operator is <, the redirection refers to the standard  input
     (file descriptor 0).  If the first character of the redirec-
     tion operator is >, the redirection refers to  the  standard
     output (file descriptor 1).
                                                                 
     The word following the redirection operator in the following
     descriptions,  unless otherwise noted, is subjected to brace
     expansion, tilde  expansion,  parameter  expansion,  command
     substitution, arithmetic expansion, quote removal, and path-
     name expansion.  If it expands to more than one  word,  bash
     reports an error.


     Note that the order of  redirections  is  significant.   For
     example, the command

          ls > dirlist 2>&1
                              
     directs both standard output and standard error to the  file
     dirlist, while the command
                   
          ls 2>&1 > dirlist

     directs only the standard output to  file  dirlist,  because
     the  standard error was duplicated as standard output before
     the standard output was redirected to dirlist.

     A failure to open or create a file causes the redirection to
     fail.

...leider englisch, weil nicht an heimischem Linuxrechner[/code]
 
Oben