Problem: My second command fails. It fails because
the scripts does not send the command on the same line
as the last prompt.
Does anybody know why this problem happens?
Thank you,
Joseph
use Net::Telnet qw(TELNET_IAC TELNET_SB TELNET_SE
TELOPT_TTYPE);
## Global variables.
my $Term = "vt100";
## Main program.
{
my($host, $username, $passwd) ; #= @ARGV;
#die "usage: $0 host username passwd\n" unless
@ARGV == 3;
my $t;
my $username = 'xxxx /nocommand';
my $passwd = 'xxxx';
$host = 'xxxxxxxxx';
my $filename = 'c:/temp/telraw.txt';
my $filename2 = 'c:/temp/teltrans.txt';
$t = new Net::Telnet (Prompt => '/[:%\$]/',
Dump_log => $filename ,
input_log => $filename2
);
## Set up callbacks to negotiate terminal type.
$t->option_callback(sub {});
$t->suboption_callback(\&subopt_callback);
$t->option_accept(Do => TELOPT_TTYPE);
## Login and print value of TERM.
$t->open($host);
$t->login($username, $passwd) or die "Login
failed\n";
$t->cmd( "\n");
$t->cmd( "\n");
$t->cmd( "\n");
my $cmd = "copy xx.txt [.info]xx.txt";
my $copy=$t->cmd( String => $cmd,
Prompt => '/\$/');
print $copy;
my $cmd2 = "perl -v";
my $perl=$t->cmd( String => $cmd2,
Prompt => '/\$/');
print $perl;
$t->close;
exit;
} # end main program
sub subopt_callback {
my ($t, $option, $parameters) = @_;
my $telcmd;
if ($option == TELOPT_TTYPE) {
$telcmd = pack("C4 A* C2", TELNET_IAC,
TELNET_SB, TELOPT_TTYPE, 0,
$Term, TELNET_IAC,
TELNET_SE);
$t->put(String => $telcmd,
Telnetmode => 0);
}
1;
} # end sub subopt_callback
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail