Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
lsmod | modinfo
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
gekko247
Tux's lil' helper
Tux's lil' helper


Joined: 02 Oct 2004
Posts: 139
Location: Lancashire, UK

PostPosted: Sun Jun 19, 2005 6:52 am    Post subject: lsmod | modinfo Reply with quote

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
View user's profile Send private message
schachti
Advocate
Advocate


Joined: 28 Jul 2003
Posts: 3765
Location: Gifhorn, Germany

PostPosted: Sun Jun 19, 2005 8:07 am    Post subject: Reply with quote

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
View user's profile Send private message
STiGMaTa_ch
Veteran
Veteran


Joined: 28 Dec 2004
Posts: 1686
Location: Rüti ZH / Schweiz

PostPosted: Sun Jun 19, 2005 9:36 am    Post subject: Reply with quote

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
View user's profile Send private message
pablo_supertux
Advocate
Advocate


Joined: 25 Jan 2004
Posts: 2953
Location: Somewhere between reality and Middle-Earth and in Freiburg (Germany)

PostPosted: Sun Jun 19, 2005 11:54 am    Post subject: Reply with quote

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
View user's profile Send private message
SinoTech
Advocate
Advocate


Joined: 20 Mar 2004
Posts: 2579
Location: Neunkirchen / Saarland / Germany

PostPosted: Sun Jun 19, 2005 11:55 am    Post subject: Reply with quote

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
View user's profile Send private message
STiGMaTa_ch
Veteran
Veteran


Joined: 28 Dec 2004
Posts: 1686
Location: Rüti ZH / Schweiz

PostPosted: Sun Jun 19, 2005 2:00 pm    Post subject: Reply with quote

Wir haben alle zuviel Zeit übrig :lol:

Meine Entschuldigung... ich kompilier grad ein Grafischen Minimalsystem für uclibc und muss sowieso warten...
Back to top
View user's profile Send private message
gekko247
Tux's lil' helper
Tux's lil' helper


Joined: 02 Oct 2004
Posts: 139
Location: Lancashire, UK

PostPosted: Tue Jun 21, 2005 5:33 pm    Post subject: Reply with quote

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. :lol:


bis dann gekko
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum