Retourner au contenu associé (entrée de forum : Comment afficher du texte d'un fichier situé entre caractères spéciaux.)
Posté par Stéphane CHANDELIER le 16 mai 2006 à 09:47. En réponse au message Comment afficher du texte d'un fichier situé entre caractères spéciaux.. Évalué à 0.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# Voici donc la réponse :
Posté par Stéphane CHANDELIER . En réponse au message Comment afficher du texte d'un fichier situé entre caractères spéciaux.. Évalué à 0.
Voici donc la page HTML qui le suporte :
--------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML VERSION="2.0">
<HEAD>
<TITLE>Recherche d'occurrences dans les fichiers textes</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table border=0 width=100%>
<tr>
<P><td align=left valign=middle></P>
<P><B><FONT SIZE="6">Direction Informatique</FONT></B></P>
<P><B><FONT SIZE="4">Recherche d'occurrences dans les fichiers textes</FONT></B></P>
<P></td><td align=right valign=middle></P>
<P ALIGN="RIGHT"><IMG SRC=file:///W:/cgi-bin/dslogo.gif ALIGN="TOP" WIDTH="170" HEIGHT="60" ></P>
<P></td>
</tr>
</table></P>
<H1><FONT SIZE="2"><A HREF="/index.html">[Accueil]</FONT></A></H1>
<HR>
<FORM METHOD="POST" ACTION="http://infotst.dsp.ds/cgi-bin/recherche/cherche.cgi">
<P><INPUT TYPE="TEXT" NAME="chaine" SIZE="25"></P>
<P><INPUT TYPE="SUBMIT" NAME="recherche" VALUE="Recherche"><B> </B>
<INPUT TYPE="RESET" NAME="annule" VALUE="Annule"></P>
</FORM>
<HR>
<TABLE ALIGN=ABSCENTER CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >
</TABLE>
</BODY>
</HTML>
--------------------------------------------------------------------------
Et voici le CGI-BIN :
--------------------------------------------------------------------------
#! /bin/sh
umask 002
echo Content-type: text/html
echo
echo '<FONT >'
echo '<H2><TT>'
PATH=":/srv/www/cgi-bin:"$PATH ; export PATH
info=`cat - `
info=`echo $info | tr '&' ' ' `
for i in `echo $info `
do
cmd=`echo $i | cut -f1 -d= `
par=`echo $i | cut -f2 -d= `
case $cmd in
chaine ) chaine=$par ;;
file ) file=$par ;;
esac
done
echo "You are looking for occurrence : $chaine"
echo '<BR>'
# le code
a=`find . -name "*.txt" -type f -exec grep -in $chaine {} /dev/null \; | cut -d":" -f1 | cut -d"/" -f2 | sort -u`
echo "File(s) where occurrence were found : $a"
echo '<BR>'
for i in $a
do
echo '<BR>'
echo "Result : "
echo '<BR>'
awk 'BEGIN { RS="?" } NR==2' $i
echo '<BR>'
done
echo '</TT></H2>'
echo ' </FONT>'
--------------------------------------------------------------------------
ca marche impec !
A+++