my $ssh = new Net::Telnet ( -fhopen => $pty, -prompt => $args{prompt}, -telnetmode => 0, -cmd_remove_mode => 1, -timeout => SSH_TIMEOUT, -output_record_separator => "\r", #-errmode => sub { print "Telnet FAIL\n"; } ); Output of script execution [root@hyd1658 attribute_template]# perl test_centos.pl output is Thu Jul 4 11:18:18 IST 2019 [root@hyd1658 ~] #### my $ssh = new Net::Telnet ( -fhopen => $pty, -prompt => $args{prompt}, -telnetmode => 0, -cmd_remove_mode => 1, -timeout => SSH_TIMEOUT, -output_record_separator => "\r", #-errmode => sub { print "Telnet FAIL\n"; } ); Output of script execution [root@hyd1658 attribute_template]# perl test_centos.pl output is [root@hyd1658 ~] #### sub cmd { . . . ## Determine if we should remove the first line of output based ## on the assumption that it's an echoed back command. if ($cmd_remove_mode eq "auto") { ## See if remote side told us they'd echo. $telopt_echo = $self->option_state(&TELOPT_ECHO); $remove_echo = $telopt_echo->{remote_enabled}; } else { # user explicitly told us how many lines to remove. $remove_echo = $cmd_remove_mode; } ## Get rid of possible echo back command. while ($remove_echo--) { shift @$output; } . . .