le lun 12-11-2001 � 14:04, Fabrice FACORAT a �crit :
> le lun 12-11-2001 � 14:18, [EMAIL PROTECTED] a �crit :
> >
> > je me suis tromp�...
> >
> > #!/usr/bin/perl
> > #
> >
> >
> > $file="/tmp/file.file";
> > $expr="zsnes";
> > $motif="%-%";
> >
> > open FILE, $file || die "quel fichier ?";
> > $d="debut";
> > while (<FILE>) {
> > $d.=$_;
> > if ( $d =~ /$motif/) {
> > $d=~s/$motif//g;
> > if ($d =~ /$expr/) {
> > print $d;
> > };
> > $d = "";
> > };
> > };
> > close FILE;
> >
>
> ca marche pas
> tu pourrais me faire voir si ca marche chez toi ?
> Il s'ex�cute bien car j'ai test� la boucle
> Il s�pare bien les bloc entre %-% et %-% ( mis un print $d; juste apr�s
> $d=~s/$motif//g;
> Cependant un truc bizarre est que le test ne marche pas ensuite avec
> expr et donc il renvoie toujours une chaine vide.
> Je pousse l'investigation plus loin.
oui et non ca marche. Mais bon c'est bien ce que je veux.� peu de choses
pr�s.
en fait le prog original ne peut marcher pour zsnes car la ligne est
ainsi : zsnes:blabla soit pour lui le m�me mot. Il faudrait mettre if (
$d =~ /$expr/o ) pour qu'il renvoie quelquechose car il chercherait m�me
les sous-expressions. ensuite comme cela peut �tre case sensitive il
vaut mieux rajouter //i ( on peur avoir icq ou ICQ ou mp3 ou MP3 ).
Pour l'instant je ne garde que i car je ne veux pas qu'il cherche dans
les champs name et descriptions. j'ai une piste dans le man perl ( man
perlretut ) pour virer les 2 premiers champs, je dois comprendre comment
enchainer en 1 seule ligne le tout.
Bon comme c'est pour un outil mdk je voudrais avoir l'avis de la ML :
urpmf permet de chercher dans les sources de urpmi certaines choses. par
d�faut il cherche un fichier. Donc en faisant urpmf fichier il renvoie
les packages qui contiennent ce fichier. cela donne par exemple :
[will@bastard will]$ urpmf mpg123
xmmp:/usr/lib/xmmp/Plugins/Codecs/mpg123.so
xmmp:/usr/lib/xmmp/Plugins/Input/mpg123.so
emacs-mpg123:/etc/emacs/site-start.d/emacs-mpg123.el
emacs-mpg123:/usr/share/doc/emacs-mpg123-1.24
emacs-mpg123:/usr/share/doc/emacs-mpg123-1.24/DOCUMENTATION
emacs-mpg123:/usr/share/emacs/site-lisp/emacs-mpg123.elc
emacs-mpg123:/usr/share/emacs/site-lisp/mpg123.el
emacs-mpg123:/usr/share/xemacs/site-lisp/xemacs-mpg123.elc
freeamp:/usr/lib/freeamp/plugins/mpg123.ui
xmms:/usr/lib/xmms/Input/libmpg123.la
xmms:/usr/lib/xmms/Input/libmpg123.so
mpg123:/usr/bin/mpg123
mpg123:/usr/share/doc/mpg123-0.59r
mpg123:/usr/share/doc/mpg123-0.59r/BUGS
mpg123:/usr/share/doc/mpg123-0.59r/CHANGES
mpg123:/usr/share/doc/mpg123-0.59r/COPYING
mpg123:/usr/share/doc/mpg123-0.59r/INSTALL
mpg123:/usr/share/doc/mpg123-0.59r/JUKEBOX
mpg123:/usr/share/doc/mpg123-0.59r/README
mpg123:/usr/share/doc/mpg123-0.59r/TODO
mpg123:/usr/share/doc/mpg123-0.59r/mp3license
mpg123:/usr/share/man/man1/mpg123.1.bz2
alsaplayer:/usr/lib/alsaplayer/input/libmpg123.la
alsaplayer:/usr/lib/alsaplayer/input/libmpg123.so
man-pages-ja:/usr/share/man/ja/man1/mpg123.1.bz2
On peut aussi faire une recherche dans la description ( --description
)ou dans le r�sum� ( --summary ).
Alors que le r�sum� marche ( une seul ligne , donc no problem avec un
grep usuel ) la description merdoie. bon l� le probl�me est en passe
d'�tre r�gl�.
maintenant la question est la suivante : sous kelle forme voulez vous le
r�sultat ?
+ sous la forme compl�te ?
:nom:description:blablablabla
sachant que la description peut �tre longue, mais bon au moins vous
lisez le tout directement.
+ sous la forme abr�g� ?
nom
vous avez juste le nom du package. cependant je vais essayer de modifier
urpmq pour qu'il ait les m�me propri�t�s que rpm -qi ( affiache de au
moins le nom et la description + r�sum� du package. donc il serait
possible d'utiliser urpmq pour r�cup�rer les infos sur ces packages.
Note : bien s�r rpmdrake le fait d�j�, mais je veux que les outils en
ligne de commandes atteignent le m�me niveau que ceux en mode graphique.
c'est un peu plus dans l'esprit Linux ;) ( plus de features en ligne de
commande et de souplesse ).
Ah oui, comment modifier cela pour utiliser un pipe ? je mets un
descripteur 1 ( c'est 1 ou 2 pour stdin ? ) ?
> > > open FILE, "/tmp/fichier.file" || die "c'est quel fichier � traiter?";
> > > while (<FILE>) {
> > > if ($_ =~ /:.*:/) {
> > > split /:/;
> > > print @_[0], "\n";
> > > };
> > > };
> > > close FILE;
> > >
> > >
> > >
> > >
> > >
> > >
> > > > Salut,
> > > >
> > > > bon les gars c'est un truc assez compliqu�.
> > > > Soit un programme dont la sortie est quelquechose du genre :
> > > > %-%
> > > > nom:description:texte
> > > > %-%
> > > > %-%
> > > > nom:description:texte
> > > > %-%
> > > >
> > > > je voudrais r�cup�rer nom si et seulement si texte contient un motif que
> > > > l'on va apell� motif.
> > > > Pour cela je suis limit� � 2 outils : perl et grep.
> > > > Note je peux utiliser un script ou une longue ligne perl.
> > > >
> > > > J'avais pens� � ne proc�dure et je voudrais savoir si c'est possible :
> > > > d'abord faire perl couper entre les %-%, puis faire grep motif sur cette
> > > > partie extraite, si grep renvoie r�ponse positive alors couper et
> > > > renvoyer que le champ 1 ( $1 ) qui contient nom ou alors tout le texte.
> > > > donc en gros un traitement qui s'applique sur les blocks compris entre
> > > > %-% et %-%.
> > > >
> > > > je vais donner un exemple partique :
> > > >
> > > > [will@bastard rpmtools]$ ./parsehdlist --description
> > > > /var/lib/urpmi/hdlist.contrib.cz
> > > > [...]
> > > > %-%
> > > > zebra:description:GNU Zebra is a free software that manages TCP/IP based
> > > > routing
> > > > protocol. It takes multi-server and multi-thread approach to resolve
> > > > the current complexity of the Internet.
> > > >
> > > > GNU Zebra supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, and RIPng.
> > > >
> > > > GNU Zebra is intended to be used as a Route Server and a Route
> > > > Reflector.
> > > > It is not a toolkit, it provides full routing power under a new
> > > > architecture. GNU Zebra is unique in design in that it has a process
> > > > for each protocol.
> > > >
> > > > See the file INSTALL for building and installation instructions.
> > > >
> > > > Please send all bug reports by electronic mail to: [EMAIL PROTECTED]
> > > > %-%
> > > > %-%
> > > > ziptool:description:Medium protection is done by software for Iomega's
> > > > JAZ and ZIP drives.
> > > > jaztool and ziptool make this features available for Linux.
> > > > %-%
> > > > %-%
> > > > zloe:description:An action-packed battle to the death that puts to the
> > > > test the players'
> > > > skill, cunning and reflexes, in a soul-wrenching, nerve-wracking,
> > > > blood-chilling colliseum of evil.
> > > > %-%
> > > > %-%
> > > > zsnes:description:This is an emulator for Nintendo's 16 bit console,
> > > > called Super Nintendo
> > > > Entertainment System or Super Famicom. It features a pretty accurate
> > > > emulation
> > > > of that system's graphic and sound capabilities.
> > > > The GUI enables the user to select games, change options, enable cheat
> > > > codes
> > > > and to save the game state, even network play is possible.
> > > > %-%
> > > > %-%
> > > > zssh:description:zssh (Zmodem SSH) is a program for interactively
> > > > transferring files to/from
> > > > a remote machine while using the secure shell (ssh). It is intended to
> > > > be a
> > > > convenient alternative to scp, allowing to transfer files without having
> > > > to
> > > > open another session and re-authenticate oneself. zssh is an
> > > > interactive
> > > > wrapper for ssh used to switch the ssh connection between the remote
> > > > shell
> > > > and file transfers. Files are transferred through the zmodem
> > > > protocol,
> > > > using the rz and sz commands.
> > > > %-%
> > > >
> > > > sortie non filtr�e. maintenant la sortie filtr� devrait me renvoy� au
> > > > choix soit pour motif = protocol :
> > > >
> > > > zebra
> > > > zssh
> > > >
> > > > ou soit :
> > > > zebra:description:GNU Zebra is a free software that manages TCP/IP based
> > > > routing
> > > > protocol. It takes multi-server and multi-thread approach to resolve
> > > > the current complexity of the Internet.
> > > >
> > > > GNU Zebra supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, and RIPng.
> > > >
> > > > GNU Zebra is intended to be used as a Route Server and a Route
> > > > Reflector.
> > > > It is not a toolkit, it provides full routing power under a new
> > > > architecture. GNU Zebra is unique in design in that it has a process
> > > > for each protocol.
> > > >
> > > > See the file INSTALL for building and installation instructions.
> > > >
> > > > Please send all bug reports by electronic mail to: [EMAIL PROTECTED]
> > > >
> > > > zssh:description:zssh (Zmodem SSH) is a program for interactively
> > > > transferring files to/from
> > > > a remote machine while using the secure shell (ssh). It is intended to
> > > > be a
> > > > convenient alternative to scp, allowing to transfer files without having
> > > > to
> > > > open another session and re-authenticate oneself. zssh is an
> > > > interactive
> > > > wrapper for ssh used to switch the ssh connection between the remote
> > > > shell
> > > > and file transfers. Files are transferred through the zmodem
> > > > protocol,
> > > > using the rz and sz commands.
> > > >
> > > >
> > > > Bon comme vous l'aurez compris c'est pour un outils de mandrake ( urpmf
> > > > ) qui pose probl�me. J'ai essay� de voir d'o�venait le probl�me
> > > > malheureusement je n'y connait rien en perl ( j'apprend depuis le man )
> > > > et je ne suis pas tr�s fort en expression r�guli�re.
> > > > Si quelqu'un trouve la r�ponse et que le changement est accept� dans le
> > > > CVS de mandrakesoft, c'est s�r que je cite son nom dans mon entr�e CVS
> > > > avec un gros merci ( de l� � savoir si cela apparaitra au changelog de
> > > > la prochaine .... ).
> > > >
> > > >
> > >
> > >
> >
> > --
> > Thomas Nagy
> >
> > DYSLEXICS OF THE WORLD, UNTIE!
> >
> >
> > ----
> >
>
> > Vous souhaitez acquerir votre Pack ou des Services MandrakeSoft?
> > Rendez-vous sur "http://www.mandrakestore.com"
> >
> --
> http://perso.wanadoo.fr/linux_wizard/index.html
> -
> <Czara1960> je ne peut pas monter mon cdrom avec KDE
>
> - #linuxfr
>
>
> ----
>
> Vous souhaitez acquerir votre Pack ou des Services MandrakeSoft?
> Rendez-vous sur "http://www.mandrakestore.com"
>
--
http://perso.wanadoo.fr/linux_wizard/index.html
-
La t�te me tourne, il faut que je parte.
Vous souhaitez acquerir votre Pack ou des Services MandrakeSoft?
Rendez-vous sur "http://www.mandrakestore.com"