[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] telnet client/server example



Um 20:33 Uhr -0900 23.11.2000, schrieb nellA hciR:
>iH
>
>i am looking for a simple client/server example for MacPerl. all the
>examples i have found thus far seem to die using the 'fork' command.

What about this as a starter?
(your subject specifies "telnet", a full server/client sample needs
much much more)

#!perl -w

use Net::Telnet;

# global
$username = "report";
$password = "<your-password>";
$host = "<your-host>"; $prompt = '<machine>:\/home\/report > ';

$t = Net::Telnet->new( Timeout => 10, Prompt => '/^<your-host>/' );
$t->open( $host) or die "can't connect to $username/$password@$host: $!\n$^E\n";

# $t->login($username, $password) or die "can't login to $username/$password@$host: $!\n$^E\n";
$t->waitfor( '/Anmelden: /' );
$t->print( ($username ) );
$t->waitfor( '/Kennwort von report: /' );
$t->print( ($password ) );
$t->waitfor( "/$prompt/" );

$t->prompt("/$prompt\$/");

@lines = $t->cmd("/usr/bin/w");
print @lines;

$t->close;

__END__


Axel

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org