$telnet_box->open("$host") || die "Failed to connect to $host $!"; $telnet_box->login($user_name, $password) || die "Failed to log onto $host. The username or password is wrong$!"; @$lines = $telnet_box->cmd("perl expect_execute.pl"); #### $exp_inst->log_file("$templog", "w"); $exp_inst->expect($timeout, [ '-re' , $prompt, sub { my $fh = shift; $fh->send("$command\n"); } ], [ timeout => sub { my_die "unable to get the prompt $prompt"; } ] ); #### prompt> command More ... #### prompt> command xyz yy prompt>