Closed

Pasar código de PERL a Python 3

Buenas. Tengo un script en perl que necesito transformarlo a Python 3

use Net::Telnet ();

use Data::Dumper;

use strict;

(my $path = $0) =~ s/\/?[^\/]*\z//; # directorio donde reside el script

sub new

{

my ($class, $args) = @_;

my $hdt = "A001";

my $host = "123.456.789";

my $opcuser = "user_123";

my $opcpass = "pass_123";

my $hdtuser = 'csvsys';

my $hdtpass = 'csv_sys';

my $timeout = 30;

my $t = new Net::Telnet (

Timeout => $timeout

, Binmode => 0

, Errmode => 'die' #\&terror

, Prompt => '/>$/' );

my $fninput = "$path/log/input_$[login to view URL]";

my $fhinput = $t->input_log($fninput);

$t->open($host);

# Login OPC

$t->waitfor('/login: ?$/i');

$t->print($opcuser);

$t->waitfor('/password: ?$/i');

$t->print($opcpass);

# Login HDT

#$t->waitfor(Match => '/enter user name$/i', Timeout => $timeout*3);

#$t->waitfor('/>$/');

$t->waitfor(Match => '/>$/', Timeout => $timeout*3);

$t->print($hdtuser);

#$t->waitfor('/enter password$/i');

$t->waitfor('/>$/');

$t->print($hdtpass);

# Going to CI mode

$t->waitfor(Match => '/MORE\.\.\./', Timeout => $timeout*3);

$t->print(chr(13)); # enter

$t->waitfor('/>$/');

$t->print('quit all');

$t->waitfor('/>$/');

return bless {

hdt => $hdt

, host => $host

, opcuser => $opcuser

, telnet => $t

, fhinput => $fhinput

, timeout => $timeout

}, $class;

}

sub check

{

my $self = shift;

my $hdt = $self->{hdt};

my $opcuser = $self->{opcuser};

my $t = $self->{telnet};

my $fhinput = $self->{fhinput};

my $timeout = $self->{timeout};

my $vplevels = [];

my $key;

my $value;

# QUERYDMC

#

$t->print('cornerstone;cveqpt;cvprov;cvpath');

$t->waitfor('/>$/');

$t->print("querycp");

my ($pmatch, $match) = $t->waitfor (

Match => '/>$/',

Timeout => $timeout*3

);

my $salida = ($pmatch =~ s/querycp//r);

my @mi_matriz = obtener_matriz_campos($salida);

leer_matriz( @mi_matriz );

return $vplevels;

}

sub DESTROY

{

my $self = shift;

my $t = $self->{telnet};

my $fhinput = $self->{fhinput};

# Logout

$t->print('logout');

$t->waitfor('/press return to exit\.$/i');

$t->print(chr(13)); # enter

close $fhinput;

}

sub terror # telnet error

{

my $msg = shift;

die "telnet error - $msg\n";

}

return 1;

# vi: ts=4 sw=4

Solo personas que hayan trabajado con conexiones telnet Perl y Python 3

Solo mirare propuesta que coloquen al prinicipio "HELLO - 12-10-2021"

Gracias.

Skills: Python, Software Architecture, Linux, Perl

See more: rhce know perl python, create php document perl python, extracting data html file perl python, html formmail php perl python, 3dsmax script perl python, asterisk written perl python, bot en perl python, free lance projects perl python, pty program perl python, scraping php perl python, bash perl python, telecom perl python, perl python seo, automation perl python, automation perl python ruby, document parsing perl python, programmer perl python, javascript html5 perl python, perl python website

About the Employer:
( 4 reviews ) Calabozo, Venezuela

Project ID: #31794559

1 freelancer is bidding on average $30 for this job

(1197 Reviews)
7.7