私の場合、次のような感じのスクリプトで動きます。 一応、ログインしてコマンド実行程度なら、大丈夫のようです。 環境は perl 5.00503 + Expect-1.08 + FreeBSD 4.2-BETA です。 #!/usr/bin/perl use Expect; my $user = 'rose'; my $password = 'password'; my $prompt = 'host\{rose\}\d+\s'; my @cmdlist = ( 'ls -alF', 'ps -auxw', 'exit', ); my $telnet = Expect->spawn("telnet localhost"); $telnet->expect(30,"login: ") || die "NO login prompt"; print $telnet "$user\r"; $telnet->expect(30,"assword:") || die "NO password prompt"; print $telnet "$password\r"; my $match = $telnet->expect( 30, "closed by foreign host", "-re", $prompt ); die "refused by server\n" if $match == 1; die "NO shell prompt, ".$telnet->exp_error()."\n" unless $match; foreach $cmd ( @cmdlist ) { print $telnet "$cmd\r"; my $match = $telnet->expect( 30, "closed by foreign host", "-re", $prompt ); last if $match == 1; die "NO prompt after command\n" if $telnet->exp_error(); } $telnet->hard_close(); exit; |