IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Web Perl Discussion :

Résultat d'une commande en html ou php


Sujet :

Web Perl

  1. #1
    Membre régulier Avatar de loopback
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    170
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 170
    Points : 113
    Points
    113
    Par défaut Résultat d'une commande en html ou php
    Salut,
    voilà je cherche le moyen de, via un script .cgi ou .pl d'afficher le résultat de cette commande unix sur le serveur web :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    pure-ftpwho -w >/usr/local/httpd/htdocs/traffic_ftp.html
    Voici le résultat sur le shell:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    linux~#:pure-ftpwho -w
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    		  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
     <meta http-equiv="Content-Type"
    	   content="text/html; charset=ISO-8859-15" />
     <title>Pure-FTPd server status</title>
     <style type="text/css">
    html {
     background-color: #369;
    }
    body {
     background-color: #fff;
     color: #000;
     margin: 12px;
     padding: 8px;
     border: 2px solid #000;
     font-family: "Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
     font-size: 0.8em;
    }
    h1 {
     text-align: center;
     border-bottom: 1px solid #666;
     margin: 0.5em 1em;
    }
    #ftp-status {
     text-align: center;
    }
    table {
     margin: 0 auto;
    }
    thead th {
     background-color: #369;
     color: #fff;
    }
    th,td {
     padding: 0.1em 0.5em;
    }
    tr:hover {
     background-color: #def;
    }
     </style>
    </head>
    <body>
    <h1>Pure-FTPd server status</h1>
    <div id="ftp-status">
     <table summary="Pure-FTPd server status">
      <thead>
       <tr>
    	<th scope="col">PID</th>
    	<th scope="col">Account</th>
    	<th scope="col">Time</th>
    	<th scope="col">State</th>
    	<th scope="col" abbr="File">File name</th>
    	<th scope="col" abbr="Peer">Remote host</th>
    	<th scope="col" abbr="Kb">Kbytes</th>
    	<th scope="col" abbr="Local">Local host</th>
       </tr>
      </thead>
      <tbody>
       <tr>
    	<th scope="row">18365</th>
    	<td>glinux</td>
    	<td>00:01</td>
    	<td>IDLE</td>
    	<td>&nbsp;</td>
    	<td>localhost.localdomain</td>
    	<td>&nbsp;</td>
    	<td>localhost.localdomain:21</td>
       </tr>
      </tbody>
     </table>
    </div>
    </body>
    </html>
    Et voici le résultat sur le navigateur:



    Comment faire ?

    Car je dois chaque fois tapper la commande sur le shell et ensuite me dirigez vers la page pour afficher le résultat et j'aimerais que ça se fasse automatiquement dés que je vais sur http://localhost/traffic_ftp.html ou http://localhost/script_traffic.cgi

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    tu cree un script cgi dans lequel tu lance la commande system. Puis tu redirige ta page cgi vers la page cree. Faut biensur que ta page soit dans le repertoire www.
    voilà

  3. #3
    Membre régulier Avatar de loopback
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    170
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 170
    Points : 113
    Points
    113
    Par défaut
    merci je vois un peu le mécanisme.
    Mais le problème c pour faire le script cgi !!
    Pourriez-vous me donner un coup de main pour, au moins, commencer à le créer car en programmation je débute et je sais vraiment pas par où commencer.

  4. #4
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    déjà assure toi d'avoir le module CGI d'installé sur ta machine.
    Voici un script de base. essaye déjà de la faire fonctionner. Il doit etre mis dans le repertoire cgi-bin. En cas d'internal servor error, regarde les log
    Regarde la doc sur les cgi en perl, google est ton ami, tu as aussi ceci :
    http://perl.enstimac.fr/ModulesFr/CGI.html

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #!/usr/bin/perl -w
    use strict;
    use Carp;
    use CGI;
     
    my $cgi = new CGI;
    print $cgi->header();
    print $cgi->start_html();
    print "<h2>Bonjour tout le monde</h2>";
    print $cgi->end_html();
    Bon courage

  5. #5
    Membre régulier Avatar de loopback
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    170
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 170
    Points : 113
    Points
    113
    Par défaut
    merci le "boujour tout le monde" fonctionne.
    Mais à l'installation d'apache il y a déjà un fichier 'test-cgi' qu'il suffit de mettre à 755 pour tester le cgi.

  6. #6
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    dans ce cas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #!/usr/bin/perl -w
    use strict;
    use Carp;
    use CGI;
     
    my $url_redirection = "/toto/traffic_ftp.html";
    system("pure-ftpwho -w >/var/www/toto/traffic_ftp.html");
    my $cgi = new CGI;
    print $cgi->header(-Refresh=>"5; URL=$url_redirection");
    print $cgi->start_html();
    print "<h2>Generation de la page  pure ftp</h2>";
    print "Vous allez être redirige dans 5 secondes";
    print $cgi->end_html();
    voilà

Discussions similaires

  1. Récupérer le résultat d'une commande shell
    Par espadon1 dans le forum Langage
    Réponses: 4
    Dernier message: 02/06/2006, 10h01
  2. Trier le résultat d'une commande dir?
    Par Johns dans le forum Langage
    Réponses: 6
    Dernier message: 13/03/2006, 17h24
  3. Récupération du résultat d'une commande shell
    Par klu dans le forum Langage
    Réponses: 8
    Dernier message: 16/02/2006, 23h34
  4. Réponses: 2
    Dernier message: 02/01/2006, 10h39
  5. Ecrire le résultat d'une commande dans un fichier de l' OS
    Par Labienus dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 26/02/2004, 11h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo