can you convert this perl code to python code :
$list = $ARGV[0];
open (PASSFILE, "$list") || die "[-] Can't open the List of password file !";
@strings = <PASSFILE>;
close PASSFILE;
Thanks
can you convert this perl code to python code :
$list = $ARGV[0];
open (PASSFILE, "$list") || die "[-] Can't open the List of password file !";
@strings = <PASSFILE>;
close PASSFILE;
Thanks
According to this reference and this one, something like this should theoretically work...
import sys
filename = sys.argv[1] # argv[0] is the program name, like in C
f = open(filename, 'r')
strings = f.readlines()
f.close()
I don't actually know any Python, so I'll just mention that Google is your friend and you could have done exactly what I did in less time than it took you to answer the question. Sure, my syntax might be off, but you could have learned that and used the diagnostics from the Python interpreter to figure out the proper syntax.
You should accept more answers for your open questions.
EDIT: Sorry, lots of typos. I wasn't really motivated to do a syntax check when (a) I didn't know Python and (b) the questioner could have done this himself/herself and saved himself/herself a lot of time.
How about translating that to modern Perl?
use strict;
use warnings;
use IO::Handle;
my $pw_path = shift;
open my $pwh, '<', $pw_path
or die "Error opening file '$pw_path' - $!\n";
my @strings = $pwh->getlines;
$pwh->close or die "Error closing file '$pw_path' - $!\n";
Or if you like autodie
:
use strict;
use warnings;
use autodie;
use IO::Handle;
my $pw_path = shift;
open my $pwh, '<', $pw_path;
my @strings = $pwh->getlines;
$pwh->close;