Re: more regex maddness, using special chars

2004-08-01 Thread Jerry M. Howell II
On Sat, 2004-07-31 at 19:45, Jerry M. Howell II wrote:
> hello all,
> 
>I appreciate everyone that got me going in the right direction with a
> sed alternative. After some searching I even found a way to get it to
> search recursive and add an extension to the end IE .html or .php and it
> is working wonderfully. Now for the part I haven't gotten a grasp on yet
> the handling of special characters. The situation I'm dealing with right
> now is converting a string hostbyk.com//order to hostbyk.com/order in
> like 100+ html files. how would I do that with the following.
> 
> #!/bin/sh
> 
> # Need some information from you
> echo "what directory do you wish to search in?"
> read dir
> echo""
> echo "what extension?"
> read ext
> echo""
> echo "what word or string are we looking for?"
> read old
> echo ""
> echo "what do you wish to replace it with"
> read new
> 
> cd $dir
> perl -p -i -e 's/'$old/$new/g' $(find . -name \*.$ext
> 

Finally figured it out. Just in case anyone else needs to work with it
the syntax for this instance was

find . -name *.html -exec perl -pi.bak -e "s|\Q$old|$new|g" {} \;

of course this is a shell script passed through the perl interpreter so
it's not true perl but the concept still holds and when I write a true
perl script this is the way I'll write it. The important part that
allied to perl is the following

s|\Q$old|$new|g instead of s/$old/$new/g 
The \Q tells it to "quote the / in hostbyk/services instead of literally
take it as the / that separates $old from $new. Hope I explained that
well enough. If someone else is better at explaining it feel free to
elaborate. Also, if someone has a better way or alternative, feel free
to explain.

-- 
Jerry M. Howell II

email admin: usalug.org

sys admin:   hostbyk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




more regex maddness, using special chars

2004-07-31 Thread Jerry M. Howell II
hello all,

   I appreciate everyone that got me going in the right direction with a
sed alternative. After some searching I even found a way to get it to
search recursive and add an extension to the end IE .html or .php and it
is working wonderfully. Now for the part I haven't gotten a grasp on yet
the handling of special characters. The situation I'm dealing with right
now is converting a string hostbyk.com//order to hostbyk.com/order in
like 100+ html files. how would I do that with the following.

#!/bin/sh

# Need some information from you
echo "what directory do you wish to search in?"
read dir
echo""
echo "what extension?"
read ext
echo""
echo "what word or string are we looking for?"
read old
echo ""
echo "what do you wish to replace it with"
read new

cd $dir
perl -p -i -e 's/'$old/$new'/g' $(find . -name \*.$ext

thank you,
-- 
Jerry M. Howell II

email admin: usalug.org

sys admin:   hostbyk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




a sed equivelent

2004-07-26 Thread Jerry M. Howell II
hello all,

   I'm just beginning to work with sed in shell scripts I was wondering
if anyone has a simmilar script in perl they can send my way or what the
perl equivelent of the sed /s would be. Here is the coresponding shell
script if it'll help you understand what I'm trying to acomplish.

#!/bin/sh

# Need some information from you

echo "what word or string are we looking for?"
read old
echo ""
echo "what do you wish to replace it with"
read new
for script in * 
do  
sed 's/'$old'/'$new'/g' <$script> outfile
mv outfile $script  
done

sometimes this script works and sometimes it just clears the file out
leaving it empty. I need a viable alternative but don't even know where
to start. Thanks for any help you can give me.

-- 
Jerry M. Howell II

email admin: usalug.org

sys admin:   hostbyk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: can't use CPAN with Mandrake 9.2

2004-02-12 Thread Jerry M. Howell II
Understood but since I read it and had a similar issue not long ago I'll
post. from the command line type urpmi perl-devel

You are probably missing the header files needed by cpan.

On Mon, 2004-02-09 at 20:32, Brian's Linux Box wrote:
> This might be better off on a Mandrake list, but I was hoping for an
> answer here (esp. since I'm already subscribed here :-)
> 
> I tried to install Getopt:Simple via CPAN on my new Mandrake 9.2 box.
> I get this
> 
> Error: Unable to locate installed Perl libraries or Perl source
> code.
> 
> It is recommended that you install perl in a standard location
> before
> building extensions. Some precompiled versions of perl do not
> contain
> these header files, so you cannot build extensions. In such a
> case,
> please build and install your perl from a fresh perl
> distribution. It
> usually solves this kind of problem.
> 
> (You get this message, because MakeMaker could not find
> "/usr/lib/perl5/5.8.1/i386-linux-thread-multi/CORE/perl.h")
> As the note indicates - there is no perl.h in the indicated directory
> (but the directory is there)
> Do I really have to reinstall perl?  It works and is in /usr/bin
> which seems normal to me
> Brian


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




useing perl to redirect and change port #

2003-03-07 Thread Jerry M. Howell II
Hello there,

 I have a script that I hacked from cpanel to help me access a webmail MUA
that I installed. It works with opera and netscape but seems to hang in
IE. I don't know much about perl but am learning. Can someone point out
whats wrong with this script that would cuse it to hang in IE?

#!/usr/bin/perl

#open(CPCONF,"/var/cpanel/sm.conf");
#while() {
#if (/^port=(\d+)/) {
#$port = $1;
#}
#}
#close(CPCONF);
if ($port eq "") { $port = '80'; }

if ($ENV{'HTTP_HOST'} ne "") {
print "Location: http://$ENV{'HTTP_HOST'}:${port}/mta\n\n";
exit;
}

print "Location: http://$ENV{'REMOTE_ADDR'}:${port}/mta\n\n";

this script or something similar is needed to escape the cpanel base
directory and also to escape the default port of 2082 that cpanel logs
into. Thanks for any help

-- 

Jerry M. Howell II



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Editors

2002-12-17 Thread Jerry M . Howell II
vim and vi are da bomb, lol. OK, had to put that in there :). Just remember
if you have to recover your system vi is the way. But emacs is ok, it makes
a great OS :P

On Tue, 17 Dec 2002 14:20:00 -0500
Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:

> 
> > (don't be too hard on vi -- a very good editor! ) (try vim or gvim for a
> > more friendly interface).
> 
> Vim rules ;-)... so much for preventing a flame war.
> 
> http://danconia.org
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




perl and php and parseing

2002-12-15 Thread Jerry M . Howell II
Hello all,

   Not sure if any of you are familiar with the search tool called perlfect.
but if anyone is I'm useing it to index a site and have a problem, it doesn't
parse the .php files. Does anyone know if there is a way to make perl parse
php files? any modules out there for this?

-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: crypt()

2002-12-09 Thread Jerry M . Howell II
I'd like to thank everyone on and off list for thier help even the ones
that chewed me out for even thinking of writeing a perl mod that
executes as root. I don't plan on this type of code going on a prodution
server for some time but finaly got it working like it should. One bump
down, many to come. The final code looks like such.

#!/usr/local/bin/perl -w
use strict;
print "Enter your preferd username.\n";
chomp(my $username = );
print "enter your prefered password\n";
chomp(my $passwd = );
my $salt="\$1\$blahblahblah\$";
chomp(my $pwd = crypt($passwd,"$salt"));
print `/usr/sbin/useradd '$username' -p '$pwd'`;

it apears without the '' around the passwd it was passing it like a string
after all $1$ in a shell is a string the same as in perl or most programming
languages and scripts. If others are having similar problems hope this helps.
And if someone sees other ways for me to do my code, clean it, make it more 
secure I'm always with an open mind

On Sun, 8 Dec 2002 08:54:28 -0500
Jerry M. Howell II <[EMAIL PROTECTED]> wrote:

> thank you for your help, but still no dice. I am wondering what's going on here.
> I installed Crypt-PasswdMD5-1.2 perl module to make this work.
> my script is as follows (I know showing the salt isn't suposed to be done
> but before I put it to use I plan to randomly generate it)
> 
> #!/usr/bin/perl
> print "Enter your preferd username.\n";
> $username = ;
> chomp($username);
> print "enter your prefered password\n";
> $passwd = ;
> $salt="\$1\$blahblahblah\$";
> use Crypt::PasswdMD5;
> $pwd = unix_md5_crypt($passwd,$salt);
> chomp($pwd);
> print `/usr/sbin/useradd $username -p $pwd`;
> print "the password is $pwd\n";
> 
> all is done corect till it puts the passwd in /etc/shadow
> 
> here is the shadow entry
> 
> kim2:/ozTmBDXkQ3jmXzv1:12029:0:9:7:::
> 
> on the last line it prints the password to the screen and I get
> 
> the password is $1$blahblah$hWn8A/ozTmBDXkQ3jmXzv1
> 
> it looks to me like it choped the passwd at the /
> 
> grrr,
> 
> On Sun, 08 Dec 2002 13:14:23 +
> Chris Ball <[EMAIL PROTECTED]> wrote:
> 
> > >> On 8 Dec 2002 07:22:39, Jerry M. Howell II <[EMAIL PROTECTED]> said:
> > 
> >> I used the useradd -p and it doesn't insert the passwd like it
> >> should I should see something like $1$blahhblahhblahh but it
> >> doesn't do this, if I manualy insert it it works fine but it looks
> >> like print `/usr/sbin/useradd "$username" -p "$pwd"`; screws it up
> > 
> > You've been using the wrong hashing algorithm, I'm afraid.  crypt()
> > isn't used in modern UNIX password files, md5 is.  I think your code
> > will start working if you use:
> > 
> >use Crypt::PasswdMD5; 
> >$pass = unix_md5_crypt($input_pass,$salt);
> > 
> > Also, your double-quotes in the useradd command look redundant.  Try
> > removing them, if it still doesn't work.  They may been being processed
> > as part of the username/password.
> > 
> > Hope this helps,
> > 
> > - Chris.
> > -- 
> > $a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a
> > 
> > 
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> > 
> 
> 
> -- 
> Jerry M. Howell II
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: crypt()

2002-12-08 Thread Jerry M . Howell II
thank you for your help, but still no dice. I am wondering what's going on here.
I installed Crypt-PasswdMD5-1.2 perl module to make this work.
my script is as follows (I know showing the salt isn't suposed to be done
but before I put it to use I plan to randomly generate it)

#!/usr/bin/perl
print "Enter your preferd username.\n";
$username = ;
chomp($username);
print "enter your prefered password\n";
$passwd = ;
$salt="\$1\$blahblahblah\$";
use Crypt::PasswdMD5;
$pwd = unix_md5_crypt($passwd,$salt);
chomp($pwd);
print `/usr/sbin/useradd $username -p $pwd`;
print "the password is $pwd\n";

all is done corect till it puts the passwd in /etc/shadow

here is the shadow entry

kim2:/ozTmBDXkQ3jmXzv1:12029:0:9:7:::

on the last line it prints the password to the screen and I get

the password is $1$blahblah$hWn8A/ozTmBDXkQ3jmXzv1

it looks to me like it choped the passwd at the /

grrr,

On Sun, 08 Dec 2002 13:14:23 +
Chris Ball <[EMAIL PROTECTED]> wrote:

> >> On 8 Dec 2002 07:22:39, Jerry M. Howell II <[EMAIL PROTECTED]> said:
> 
>> I used the useradd -p and it doesn't insert the passwd like it
>> should I should see something like $1$blahhblahhblahh but it
>> doesn't do this, if I manualy insert it it works fine but it looks
>> like print `/usr/sbin/useradd "$username" -p "$pwd"`; screws it up
> 
> You've been using the wrong hashing algorithm, I'm afraid.  crypt()
> isn't used in modern UNIX password files, md5 is.  I think your code
> will start working if you use:
> 
>use Crypt::PasswdMD5; 
>$pass = unix_md5_crypt($input_pass,$salt);
> 
> Also, your double-quotes in the useradd command look redundant.  Try
> removing them, if it still doesn't work.  They may been being processed
> as part of the username/password.
> 
> Hope this helps,
> 
> - Chris.
> -- 
> $a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: crypt()

2002-12-08 Thread Jerry M . Howell II
ok,

   I finaly got it figured out just one last problem. I used
the useradd -p and it doesn't insert the passwd like it should
I should see something like $1$blahhblahhblahh but it doesn't
do this, if I manualy insert it it works fine but it looks like
print `/usr/sbin/useradd "$username" -p "$pwd"`;

screws it up, any sugestions?


On Sun, 08 Dec 2002 13:12:11 +0100
"Mystik Gotan" <[EMAIL PROTECTED]> wrote:

> Hiya.
> 
> Salt is just a thing which helps you encoding the stuff.
> 
> From a book:
> 
> 
> The crypt Function
> The crypt function encrypts a string using the NBS Data Encryption Standard 
> (DES) algorithm.
> 
> The syntax for the crypt function is
> 
> 
> result = crypt (original, salt);
> 
> 
> original is the string to be encrypted, and salt is a character string of 
> two characters that defines how to change the DES algorithm (to make it more 
> difficult to decode). These two characters can be any letter or digit, or 
> one of the . and / characters. After the algorithm is changed, the string is 
> encrypted using the resulting key.
> 
> result is the encrypted string. The first two characters of result are the 
> two characters specified in salt.
> 
> You can use crypt to set up a password checker similar to those used by the 
> UNIX login. Listing 14.2 is an example of a program that prompts the user 
> for a password and compares it with a password stored in a special file.
> 
> 
> 
> 
> 
> 
> 
> Listing 14.2. A program that asks for and compares a password.
> 
> 
> 1:  #!/usr/local/bin/perl
> 
> 2:
> 
> 3:  open (PASSWD, "/u/jqpublic/passwd") ||
> 
> 4:  die ("Can't open password file");
> 
> 5:  $passwd = ;
> 
> 6:  chop ($passwd);
> 
> 7:  close (PASSWD);
> 
> 8:  print ("Enter the password for this program:\n");
> 
> 9:  system ("stty -echo");
> 
> 10: $mypasswd = ;
> 
> 11: system ("stty echo");
> 
> 12: chop ($mypasswd);
> 
> 13: if (crypt ($mypasswd, substr($passwd, 0, 2)) eq $passwd) {
> 
> 14: print ("Correct! Carry on!\n");
> 
> 15: } else {
> 
> 16: die ("Incorrect password: goodbye!\n");
> 
> 17: }
> 
> 
> 
> 
> 
> 
> 
> 
> $ program14_2
> 
> Enter the password for this program:
> 
> bluejays
> 
> Correct! Carry on!
> 
> $
> 
> 
> 
> 
> Note that the password you type is not displayed on the screen.
> 
> Lines 3-7 retrieve the correct password from the file /u/jqpublic/passwd. 
> This password can be created by another call to crypt. For example, if the 
> correct password is sludge, the call that creates the string now stored in 
> $passwd could be the following, where $salt contains some two-character 
> string:
> 
> 
> $retval = crypt ("sludge", $salt);
> 
> 
> After the correct password has been retrieved, the next step is line 8, 
> which asks the user to type a password. By default, anything typed in at the 
> keyboard is immediately displayed on the screen; this behavior is called 
> input echoing. Input echoing is not desirable if a password is being typed 
> in, because someone looking over the user's shoulder can read the password 
> and break into the program.
> 
> To make the password-checking process more secure, line 9 calls the UNIX 
> command stty -echo, which turns off input echoing; now the password is not 
> displayed on the screen when the user types it. After the password has been 
> entered, line 11 calls the UNIX command stty echo, which turns input echoing 
> back on.
> 
> Line 13 calls crypt to check the password the user has entered. Because the 
> first two characters of the actual encrypted password contain the 
> two-character salt used in encryption, substr is used to retrieve these two 
> characters and use them as the salt when encrypting the user's password. If 
> the value returned by crypt is identical to the encrypted password, the 
> user's password is correct; otherwise, the user has gotten it wrong, and die 
> terminates the program. (A gentler password-checking program usually gives 
> the user two or three chances to type a password before terminating the 
> program.)
> 
> This password checker is secure because the actual password does not appear 
> in the program in unencrypted form. (In fact, because the password is in a 
> separate file, it does not appear in the program at all.) This makes it 
> impossible to ob

crypt()

2002-12-08 Thread Jerry M . Howell II
hello there,

   Got another question. as far as I know I need the following to encrypt
a passwd in perl. I plan to use it to add a users to my /etc/passwd /etc/shadow
and /etc/group now I got a question cuz most newbees do :) what am I missing
in this script I've narowed it down to the crypt command and found out in the
cammel book it should be crypt(plaintext,salt) if I understood it corectly.
what do I need for the salt
my script is the following (don't laugh to hard :))

#!/usr/bin/perl
print "Enter your preferd username.\n";
$username = ;
chomp($username);
print "enter your prefered password\n";
$passwd = ;
$passwd=crypt($passwd);
chomp($passwd);
print `/usr/sbin/useradd "$username" -p "$passwd"`;

-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




superuser

2002-12-08 Thread Jerry M . Howell II
hello all,

   I am looking for a command and the best way to give a non-superuser
perlscript, ie, one that will be used in a web form the ability to add
a user using the standard unix admin tools like useradd. Can anyone
give me some input on this? can it be done through sudo safely? Is
there a beter way? I've heard someone around here mention suexec, would
that work in a web environment safely or should I look at an alternative
route? If so what route should I look?

-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: book for perl ???

2002-11-22 Thread Jerry M . Howell II
O'Riely puts out a book most of my perl friends call the cammel book.
Probably becuse of the cammel on the front cover, that would be my
recomendation


On Fri, 22 Nov 2002 17:23:41 +0530
Sunil Sonnad <[EMAIL PROTECTED]> wrote:

> Hi all,
>   Which book would make the gr8 reference for PERL ???
>
>  S.
> 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




perl modules for a webhost

2002-11-21 Thread Jerry M . Howell II
Hello there all again,

   I would like to know what perl modules Are probably used most often on
a webhost server. I had someone try and run the Ikonboard and I found out
we didn't have the module installed, after I installed it the board ran
flawless but it also got me thinking about all the mods we might not have
that our cusomers might need. Any sugestions, webpages that list this or
anything that might help me?

thnx

-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]