C
Chuck
I am a new user to perl - trying to teach myself enough perl to do a
specific task to be used in conjunction with other software I have
developed.
I am a software developer and use a web site for distribution of the
software. The download folder of this web site uses password protection via
..htpasswd
I created another windows based program that creates the .htpasswd file
locally - each of my software users has their own username and password to
download updates to the software - what I need to do with perl is to loop
through the local .htpasswd file that is created by the other windows app
and crypt() the password. I have already done this by looping through the
local .htpasswd file in my windows based code and copying the password to be
encrypted to the local clipboard on the computer that I use to maintain my
user list. Then I call perl from within my windows based code, get the data
from the clipboard, crypt() the password, and then copy it back to the
clipboard, then get the clipboard data in my windows based code, and update
the local .htpasswd file with the encrypted string for the password. Then
after the process is done I use FTP to upload the .htpasswd file to the
protected folder on the web server. This all works great but I want to loop
through the entire file using perl rather that calling perl for each record
in the file - this is rather slow because perl needs to be loaded for each
record in the local .htpasswd file rather than only loading once.
I have been through several tutorials and did google searches to see if I
could determine why my perl script is not working but could not get it to
work. I ran the script though the perl debugger and made sure there were no
errors in the script that the debugger could find. I am using wperl.exe so
the console window does not show but have also used perl.exe.
I have been working on this for a couple of days but figured that some help
from the perl experts could expedite this for me. Any suggestions or
pointers will be greatly appreciated.
The script runs without any error messages but does not appear to read data
from the already existing .htpasswd file and it does not create the new
..htpasswd2 file that I rename to the original file name after the loop is
finished - this is my script;
use strict;
use warnings;
my $text1;
my $text2;
my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
open(OLD, '<', $OldFile) or die "$!\n";
open(NEW, '>', $NewFile) or die "$!\n";
while (<OLD>) {
$text1 = substr($_,0,5);
$text2 = crypt(substr($_,5,8),substr($_,13,2));
print NEW "$text1 $text2 /n";
}
close OLD or die "$!\n";
close NEW or die "$!\n";
rename($NewFile,$OldFile) or die "$!\n";
The files do not need to be locked as only one person will be running this
script at any given time.
--
regards,
Chuck
CommPay Software
specific task to be used in conjunction with other software I have
developed.
I am a software developer and use a web site for distribution of the
software. The download folder of this web site uses password protection via
..htpasswd
I created another windows based program that creates the .htpasswd file
locally - each of my software users has their own username and password to
download updates to the software - what I need to do with perl is to loop
through the local .htpasswd file that is created by the other windows app
and crypt() the password. I have already done this by looping through the
local .htpasswd file in my windows based code and copying the password to be
encrypted to the local clipboard on the computer that I use to maintain my
user list. Then I call perl from within my windows based code, get the data
from the clipboard, crypt() the password, and then copy it back to the
clipboard, then get the clipboard data in my windows based code, and update
the local .htpasswd file with the encrypted string for the password. Then
after the process is done I use FTP to upload the .htpasswd file to the
protected folder on the web server. This all works great but I want to loop
through the entire file using perl rather that calling perl for each record
in the file - this is rather slow because perl needs to be loaded for each
record in the local .htpasswd file rather than only loading once.
I have been through several tutorials and did google searches to see if I
could determine why my perl script is not working but could not get it to
work. I ran the script though the perl debugger and made sure there were no
errors in the script that the debugger could find. I am using wperl.exe so
the console window does not show but have also used perl.exe.
I have been working on this for a couple of days but figured that some help
from the perl experts could expedite this for me. Any suggestions or
pointers will be greatly appreciated.
The script runs without any error messages but does not appear to read data
from the already existing .htpasswd file and it does not create the new
..htpasswd2 file that I rename to the original file name after the loop is
finished - this is my script;
use strict;
use warnings;
my $text1;
my $text2;
my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
open(OLD, '<', $OldFile) or die "$!\n";
open(NEW, '>', $NewFile) or die "$!\n";
while (<OLD>) {
$text1 = substr($_,0,5);
$text2 = crypt(substr($_,5,8),substr($_,13,2));
print NEW "$text1 $text2 /n";
}
close OLD or die "$!\n";
close NEW or die "$!\n";
rename($NewFile,$OldFile) or die "$!\n";
The files do not need to be locked as only one person will be running this
script at any given time.
--
regards,
Chuck
CommPay Software