Here is the script, just in case some good soul is wishing to help me:
#!/usr/local/bin/perl
use Net::Telnet qw(TELOPT_TTYPE);
use Term::VT102;




#####
$username="xxx";
$passwd="xxx";
$server="10.52.36.17";
$logfile="script.log";
######

    $t = new Net::Telnet (Timeout => 10);
    $t->open($server);
    $fh = $t->dump_log($logfile);
    $t->login($username, $passwd) or die "Cannot login";
    $t->option_callback (\&opt_callback);
    $t->option_accept ('Do' => TELOPT_TTYPE);
    $t->suboption_callback (\&subopt_callback);
$cmd="su -";
$cmd2="rootpassword";

# here I su to root user
$su=$t->cmd( String => $cmd,
Prompt  => '/root/');
print $su;

# send root password
$pw = $t->cmd($cmd2);
print $pw;

#set TERM
$cmd="export TERM=ansi";
esegui();

#flush buffer
$|=1;

my $vt = Term::VT102->new (
  'cols' => 80,
  'rows' => 25,
);

#
$vt->callback_set ('OUTPUT', \&vt_output, $t);
$command="cicsterm -Q -A -T=OPT1*9700702*0005984044*0000000*01\n";
$vt->resize(80,25);
$vt->process ($command);

	print "\eH";	# return to the top left of the (real) screen
	for (my $row = 1; $row <= $vt->rows (); $row++) {
		printf "%s\n", $vt->row_plaintext ($row);
	}
	printf "Cursor position: (%d, %d)",
	  $vt->x (),
	  $vt->y ();

$vt->process ($command);

	for (my $row = 1; $row <= $vt->rows (); $row++) {
		printf "%s\n", $vt->row_plaintext ($row);
	}


$t->close;


print "\n**************end script************\n";
close $fh;
exit;


sub esegui {
@lines = $t->cmd( String => $cmd,
Prompt  => '/\@svuni046\/>/'); 
print @lines;	
	}


#
sub opt_callback {
	my ($obj,$opt,$is_remote,$is_enabled,$was_enabled,$buf_position) = @_;

	if ($opt == TELOPT_TTYPE and $is_enabled and !$is_remote) {
		#
		# Perhaps do something if we get TELOPT_TTYPE switched on?
		#
	}

	return 1;
}


# Callback for sub-option handling - for Net::Telnet.
#
sub subopt_callback {
	my ($obj, $opt, $parameters) = @_;
	my ($ors_old, $otm_old);

	# Respond to TELOPT_TTYPE with "I'm a VT102".
	#
	if ($opt == TELOPT_TTYPE) {
		$ors_old = $obj->output_record_separator ('');
		$otm_old = $obj->telnetmode (0);
		$obj->print (
		  "\xff\xfa",
		  pack ('CC', $opt, 0),
		  'vt102',
		  "\xff\xf0"
		);
		$obj->telnetmode ($otm_old);
		$obj->output_record_separator ($ors_old);
	}

	return 1;
}


# Callback for OUTPUT events - for Term::VT102.
#
sub vt_output {
	my ($vtobject, $type, $arg1, $arg2, $private) = @_;

	if ($type eq 'OUTPUT') {
		$private->print ($arg1);
	}
}


In reply to Re: Re: Re: Net::Telnet + Term::VT102 sample by golemwashere
in thread Net::Telnet + Term::VT102 sample by golemwashere

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.