Hallo Leute, mich würde mal folgendes interessieren, gibt es eine Möglichkeit, um bei bestimmten Befehlen zusätzlich das Ergbnis in einer Datei abspeichern zu lassen? Also Beispiel: Ich führe auf der Konsole bash ein ./configure aus und möchte hinterher das was auf der Konsole an Meldungen usw. erscheint in einer Logdatei sozusagen haben ... - oder ich führe ein "make" aus und möchte es auch in einer Datei haben ... Gibts da eine Möglichkeit, das bei Ausführung dieser Beispielbefehle sozusagen zugleich eine Art Logdatei erstellt wird? Besten Dank vorab. MfG. Sascha
Sascha Blum wrote:
mich würde mal folgendes interessieren, gibt es eine Möglichkeit, um bei bestimmten Befehlen zusätzlich das Ergbnis in einer Datei abspeichern zu lassen?
Ja: tee cat /etc/fstab | tee fstab.log Wenn Du komplette Shell-Sitzungen mitloggen willst (inkl. Deiner Befehle), dann schau Dir 'script' an. HTH, Stefan
Hallo, Am Samstag, 21. Februar 2004 17:53 schrieb Stefan Waidele jun.:
mich würde mal folgendes interessieren, gibt es eine Möglichkeit, um bei bestimmten Befehlen zusätzlich das Ergbnis in einer Datei abspeichern zu lassen?
Ja: tee cat /etc/fstab | tee fstab.log
also hieße das jetzt z.B. für ./configure oder ein make wie folgt oder seh ich das nun falsch? ./configure --schalter-xy | tee configure.log bzw. make | tee make.log OK tee muss ich dann zuvor noch installieren ... - das ist klar.
Wenn Du komplette Shell-Sitzungen mitloggen willst (inkl. Deiner Befehle), dann schau Dir 'script' an.
kann ich mal machen ... MfG. Sascha
Sascha Blum wrote:
mich würde mal folgendes interessieren, gibt es eine Möglichkeit, um bei bestimmten Befehlen zusätzlich das Ergbnis in einer Datei abspeichern zu lassen?
Also Beispiel:
Ich führe auf der Konsole bash ein ./configure aus und möchte hinterher das was auf der Konsole an Meldungen usw. erscheint in einer Logdatei sozusagen haben ... - oder ich führe ein "make" aus und möchte es auch in einer Datei haben ...
http://www.thomashertweck.de/kernel24.html#sonstiges, 2. Punkt. Die genannte Loesung von Stefan hat den Nachteil, dass nur stdout in die Datei umgeleitet wird, nicht aber stderr, was gerade beim Konfigurieren und Compilieren von Software aber besonders wichtig ist. CU, Th.
Hallo, Am Samstag, 21. Februar 2004 18:45 schrieb Thomas Hertweck: [...]
http://www.thomashertweck.de/kernel24.html#sonstiges, 2. Punkt. Die genannte Loesung von Stefan hat den Nachteil, dass nur stdout in die Datei umgeleitet wird, nicht aber stderr, was gerade beim Konfigurieren und Compilieren von Software aber besonders wichtig ist.
du meinst das => make bzImage 2>&1 | tee make_bzImage.log da? Dann hätte ich noch eine Frage, weil ich versteh das leider nicht ganz ... schreib ich dann egal was ich per make dann compilieren will immer make bzImage 2>&1 | tee make_bzImage.log oder bezieht sich das nur auf Kernel compilieren? Was ich will ist schon das Ergebnis in einer Datei haben, darin sollen aber auch sämtliche Fehler usw. aufgelistet sein ... Ich hatte mal spaßeshalber es so versucht: make | tee make.log nur das was danach im Logfile zufinden war, war nicht ganz 1:1 das selbe, wie ich auf der Konsole zu sehen bekam, da wurden sozusagen einige Fehlermeldungen unterschlagen und sie standen nicht im Logfile drin, aber auf der Konsole schon ... - was ich möchte und brauche, ist das alles in dem Logfile zufinden ist, also alle Fehlermeldungen inklusive! Besten Dank vorab. MfG. Sascha
Sascha Blum wrote:
Was ich will ist schon das Ergebnis in einer Datei haben, darin sollen aber auch sämtliche Fehler usw. aufgelistet sein ...
Ich hatte mal spaßeshalber es so versucht:
make | tee make.log
nur das was danach im Logfile zufinden war, war nicht ganz 1:1 das selbe,
klar ;) Du hast nur stdout in die Datei geschrieben, Du willst aber stdout und stderr haben, daher erst mal mit 2>&1 stderr und stdout zusammenfassen, | pipen tee FILE und sowohl auf die Konsole als auch in Datei schreiben. das kannst Du immer machen, wenn Du beide Ausgaben in der Datei haben willst. Andreas
Hallo, Am Samstag, 21. Februar 2004 23:22 schrieb Andreas Loesch:
Was ich will ist schon das Ergebnis in einer Datei haben, darin sollen aber auch sämtliche Fehler usw. aufgelistet sein ...
Ich hatte mal spaßeshalber es so versucht:
make | tee make.log
nur das was danach im Logfile zufinden war, war nicht ganz 1:1 das selbe,
klar ;) Du hast nur stdout in die Datei geschrieben, Du willst aber stdout und stderr haben, daher erst mal mit
2>&1
stderr und stdout zusammenfassen,
ok zusammenfassen macht man mit 2>&1 - ok soweit nun verstanden ...
pipen
damit meinst du wohl das | dazwischen oder?
tee FILE
und sowohl auf die Konsole als auch in Datei schreiben.
das kannst Du immer machen, wenn Du beide Ausgaben in der Datei haben willst.
nur eines versteh leider nach wie vor nicht, warum steht in dem Beispiel von http://www.thomashertweck.de/kernel24.html#sonstiges => make bzImage 2>&1 | tee make_bzImage.log also ich mein, warum wird da bzImage nochmals zwischen make und dem 2>&1 da genannt? MfG. Sascha
Sascha Blum wrote:
[...] nur eines versteh leider nach wie vor nicht, warum steht in dem Beispiel von http://www.thomashertweck.de/kernel24.html#sonstiges
=> make bzImage 2>&1 | tee make_bzImage.log
also ich mein, warum wird da bzImage nochmals zwischen make und dem 2>&1 da genannt?
Du musst versuchen, Deine Gedankengaenge etwas zu abstrahieren... Versteife Dich nicht auf _genau_ die Zeile, die oben steht. Die Syntax ist im Prinzip "Befehl 2>&1 | tee log_datei". Im obigen Beispiel ist "Befehl = make bzImage" mit dem man das Erstellen eines Kernel-Images aus den Kernel-Quellen anstossen kann (darum geht es ja letztendlich im genannten Howto), und "log_datei = make_bzImage.log" ist die Datei, in der nachher die komplette Ausgabe (also stdout und stderr) stehen wird, denn der Stream stderr wird ueber 2>&1 auf stdout umgeleitet. Schau Dir mal "man bash" an, da steht einiges ueber das Problem, Stichwort "redirection". CU, Th.
On Sat, 21 Feb 2004 22:53:40 +0100 Sascha Blum <linux@saschablum.de> wrote: [...]
make bzImage 2>&1 | tee make_bzImage.log
oder bezieht sich das nur auf Kernel compilieren?
Das 'make bzImage' bezieht sich nur auf das kompilieren eines Kernels. Dadurch wird ein Kernel im bzImage Format erstellt.
Was ich will ist schon das Ergebnis in einer Datei haben, darin sollen aber auch sämtliche Fehler usw. aufgelistet sein ...
Das erreichst Du mit der Option 2>&1. Dadurch werden stdout und stderr in das Logfile geschrieben. -- MfG Sven *************************** Sven Sprengel 47800 Krefeld Germany mailto:sven_sprengel@web.de ***************************
Sascha Blum wrote:
[...] du meinst das
=> make bzImage 2>&1 | tee make_bzImage.log
da? Dann hätte ich noch eine Frage, weil ich versteh das leider nicht ganz ...
Das ist ein Beispiel zum Kernel compilieren. Es geht aber prinzipiell mit der Befehlssequenz "Befehl 2>&1 | tee log".
schreib ich dann egal was ich per make dann compilieren will immer
make bzImage 2>&1 | tee make_bzImage.log
oder bezieht sich das nur auf Kernel compilieren?
Siehe oben. Das bezieht sich natuerlich nur auf den Kernel. Vor dem 2>&1, mit dem uebrigens stderr auf stdout umgeleitet wird, steht schlicht der Befehl, der ausgefuehrt werden soll. stderr und stdout hat man somit zusammengefasst und uebergibt diesen Stream an das Programm tee, das wiederum den Stream quasi einmal in eine Datei umleitet, andererseits einfach wieder auf stdout ausgibt.
Was ich will ist schon das Ergebnis in einer Datei haben, darin sollen aber auch sämtliche Fehler usw. aufgelistet sein ...
Ich hatte mal spaßeshalber es so versucht:
make | tee make.log
nur das was danach im Logfile zufinden war, war nicht ganz 1:1 das selbe, wie ich auf der Konsole zu sehen bekam, da wurden sozusagen einige Fehlermeldungen unterschlagen und sie standen nicht im Logfile drin, aber auf der Konsole schon ... - was ich möchte und brauche, ist das alles in dem Logfile zufinden ist, also alle Fehlermeldungen inklusive!
Siehe oben. Fehler werden ueber stderr ausgegeben. Mit Deiner Befehlsfolge hast Du aber nur stdout in die Datei umgeleitet. Deswegen steht da das "2>&1" bei meiner Befehlssequenz, siehe "man bash", Kapitel "REDIRECTION" fuer Details. CU, Th.
participants (5)
-
Andreas Loesch
-
Sascha Blum
-
Stefan Waidele jun.
-
Sven Sprengel
-
Thomas Hertweck