View previous topic :: View next topic |
Author |
Message |
gekko247 Tux's lil' helper
Joined: 02 Oct 2004 Posts: 139 Location: Lancashire, UK
|
Posted: Sun Jun 19, 2005 6:52 am Post subject: lsmod | modinfo |
|
|
Hallo Zusammen,
wir haben in der Schule eine Aufgabe auf bekommen. Aber ich bekomme das einfach nicht hin, ich hoffe ihr könnt mir helfen.
Aufgabe:
- mit lsmod alle Module anzeigen lassen ( nur die Modulnamen )
- zu jeden Modulnamen alle Informationen auflisten lassen
- an wie vielen Modulen hat Jaroslav Kysela mit gearbeitet
Also mit einen
#lsmod | cut -d " " -f 1 > lsmod.txt
kann ich das ergebnis in eine Datei schreiben.
mit modinfo bekomme ich ja Informationen über ein Modul, suchen / zählen kann ich mit grep / wc.
Aber wie bekomme ich das Syntax gerecht unter?
Danke schon mal
gekko verwirrt |
|
Back to top |
|
|
schachti Advocate
Joined: 28 Jul 2003 Posts: 3765 Location: Gifhorn, Germany
|
Posted: Sun Jun 19, 2005 8:07 am Post subject: |
|
|
Du könntest xargs benutzen, oder eine Schleife wie zum Beispiel
Code: |
for MODUL in $(lsmod | cut -d " " -f 1); do
BLABLA
done
|
_________________ Never argue with an idiot. He brings you down to his level, then beats you with experience.
How-To: Daten verschlüsselt auf DVD speichern. |
|
Back to top |
|
|
STiGMaTa_ch Veteran
Joined: 28 Dec 2004 Posts: 1686 Location: Rüti ZH / Schweiz
|
Posted: Sun Jun 19, 2005 9:36 am Post subject: |
|
|
Ich denke du willst sowas:
Code: | for a in `lsmod | cut -d " " -f1 | grep -v Module`;
do
echo -e "\n";
banner $a;
modinfo $a;
if [ ! "`modinfo $a | grep Jaroslav`" = "" ];
then
echo -en "-----\033[1;31m\nJaroslav Kysela hat hier mitgearbeitet\n\033[0m-----\n";
fi;
done |
damit erhältst du schon einmal den benötigten output.
Zum Schluss lässt du halt über den gesammten Output ein Code: | grep "mitgearbeitet" | wc -l | laufen.
P.s. eventuell musst du noch vorher ein emerge banner machen.
Lieber Gruss
STiGMaTa |
|
Back to top |
|
|
pablo_supertux Advocate
Joined: 25 Jan 2004 Posts: 2953 Location: Somewhere between reality and Middle-Earth and in Freiburg (Germany)
|
Posted: Sun Jun 19, 2005 11:54 am Post subject: |
|
|
Also, mein Code
Code: |
for i in `lsmod | awk '{print $1}'`; do
MODINFO=`modinfo $i`
echo -e "\033[1;31mInformation about module $i\033[0m"
echo -e "\033[1;33m$MODINFO\033[0m"
if [ ! "`echo $MODINFO | grep Jaroslav\ Kysela`" = "" ]; then
echo -e "\033[1;32mModule $i was modifieded by Jaroslav Kysela\033[0m"
fi;
done
|
edit: wegen Lesbarkeit
edit 2: Ausgabe (nur ein kleiner Auschnitt)
Information about module snd_pcm
author: Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>
description: Midlevel PCM code for ALSA.
license: GPL
parmtype: preallocate_dma:int
parm: preallocate_dma:Preallocate DMA memory when the PCM devices are initialized.
parmtype: maximum_substreams:int
parm: maximum_substreams:Maximum substreams with preallocated DMA memory.
vermagic: 2.6.11-gentoo-r11 preempt PENTIUMIII gcc-3.3
depends: snd,snd-page-alloc,snd-timer
Module snd_pcm was modifieded by Jaroslav Kysela
Information about module snd_timer
author: Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>
description: ALSA timer interface
license: GPL
parmtype: timer_limit:int
parm: timer_limit:Maximum global timers in system.
vermagic: 2.6.11-gentoo-r11 preempt PENTIUMIII gcc-3.3
depends: snd
Module snd_timer was modifieded by Jaroslav Kysela _________________ A! Elbereth Gilthoniel!
silivren penna míriel
o menel aglar elenath,
Gilthoniel, A! Elbereth!
Last edited by pablo_supertux on Sun Jun 19, 2005 12:06 pm; edited 3 times in total |
|
Back to top |
|
|
SinoTech Advocate
Joined: 20 Mar 2004 Posts: 2579 Location: Neunkirchen / Saarland / Germany
|
Posted: Sun Jun 19, 2005 11:55 am Post subject: |
|
|
Hier mein Vorschlag:
Code: |
#!/bin/bash
# Anzahl der Module an denen kysela mitgearbitet hat
ANZAHL=0
# In einer for Schleife alle Module abarbeiten ("Module"
# wird von "cut" mit ausgegeben, ist aber kein Modul. Daher
# mit Hilfe von "sed" entfernen (Geht aber auch anders))
for i in `lsmod | cut -d ' ' -f1 | sed -n -e '/^Module$/!p'`
do
echo -e "Informationen zum Modul $i"
echo -e "##############################################"
# Modul Informationen ausgeben
modinfo $i
# Falls Kysela mitgearbeitet hat ...
if [[ `modinfo $i | grep Kysela` ]]
then
# ... Anzahl erhöhen
((ANZAHL++));
fi
echo -e "##############################################\n\n"
done
# Ausgabe an wievielen Modulen kysela Hand angelegt hat :)
echo -e "Jaroslav Kysela hat an $ANZAHL Modulen mitgearbeitet."
# Und fertig !
|
|
|
Back to top |
|
|
STiGMaTa_ch Veteran
Joined: 28 Dec 2004 Posts: 1686 Location: Rüti ZH / Schweiz
|
Posted: Sun Jun 19, 2005 2:00 pm Post subject: |
|
|
Wir haben alle zuviel Zeit übrig
Meine Entschuldigung... ich kompilier grad ein Grafischen Minimalsystem für uclibc und muss sowieso warten... |
|
Back to top |
|
|
gekko247 Tux's lil' helper
Joined: 02 Oct 2004 Posts: 139 Location: Lancashire, UK
|
Posted: Tue Jun 21, 2005 5:33 pm Post subject: |
|
|
Moin,Moin,
danke für die vielen Vorschläge. Wie ich das sehe habe ich noch eine menge zu lernen, was die Bash Programierung angeht.
Ich muss aber noch was los werden.
Ein großen Lob, ist eine super Forum hier.
bis dann gekko |
|
Back to top |
|
|
|