#!/usr/bin/perl -w use Expect; my $command = new Expect; #print $command "telnet stiletto23-cssp0\r"; $command = Expect->spawn("telnet stiletto23-cssp0") or die "Couldn't start program: $!\n"; sleep 1; #prevent output from being shown on our STDOUT $command->log_stdout(1); #wait 10 seconds for "username:" to appear unless ($command->expect(10, "username:")) { #print "timed out"; } # send "username" and a carriage return to the program print $command "admin\r"; sleep 1; print $command "netra1\r"; print "now here\n";