[11136] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4736 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 24 14:27:09 1999

Date: Sun, 24 Jan 99 11:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 24 Jan 1999     Volume: 8 Number: 4736

Today's topics:
    Re: 2nd Repost?: Win32 globbing always checks floppy (Bbirthisel)
    Re: 2nd Repost?: Win32 globbing always checks floppy (Martin Packer)
    Re: CDDB Lookup? (Rocco Caputo)
    Re: CGI.pm and Redirection question (I R A Aggie)
    Re: Do you know a good Perl debugger free ? <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Do you know a good Perl debugger free ? (Matthew Bafford)
    Re: Easy way to grep all combinations of array subscrip <jdf@pobox.com>
    Re: encryption question (quickie) (I R A Aggie)
        File Upload (Again :-) ) <nima.mortazavi@NO_SPAMallgon.se>
    Re: File Upload (Again :-) ) <jdf@pobox.com>
    Re: How long would the Unixes last without Perl? (Clay Irving)
    Re: How long would the Unixes last without Perl? <address@web.page>
    Re: How long would the Unixes last without Perl? <lusol@Pandora.CC.Lehigh.EDU>
    Re: How to insert newline break into a long string <allan@due.net>
    Re: How to insert newline break into a long string <allan@due.net>
    Re: locking file for updating miko@idocs.com
    Re: Loop + rand <allan@due.net>
    Re: Loop + rand (Matthew Bafford)
    Re: Need script for .htpasswd file <js148@hotmail.com>
    Re: perl bug with substitution via subroutine? <michael@mismatch.com>
    Re: Perl Criticism (I R A Aggie)
    Re: Perl Criticism (I R A Aggie)
    Re: Perl uses in NT ps258@hotmail.com
    Re: Problem with dbm hash <ebohlman@netcom.com>
    Re: Safely editing /etc/passwd. <vertigan@iinet.net.au>
        searching a binary file ps258@hotmail.com
    Re: searching a binary file <ebohlman@netcom.com>
    Re: searching a binary file <ebohlman@netcom.com>
        Trying to automate FTP <smiths@erols.com>
    Re: Where can I find text parsing samples <jdf@pobox.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 24 Jan 1999 15:12:02 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: 2nd Repost?: Win32 globbing always checks floppy
Message-Id: <19990124101202.02796.00001963@ng120.aol.com>

Hi Martin:

>Each time the glob is called, the floppy drive is accessed for a second or
>two, even though the a: drive isn't the one being looked at by the glob. 

It has occasionally been reported on Perl-Win32-Users that certain
virus checking software causes this behavior as a side-effect. You
might want to check the archives at the ActiveState site for details.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


------------------------------

Date: Sun, 24 Jan 1999 12:25:38 -0500
From: mpacker@concentric.net (Martin Packer)
Subject: Re: 2nd Repost?: Win32 globbing always checks floppy
Message-Id: <36ab56fd.8032399@news.mindspring.com>

On 24 Jan 1999 15:12:02 GMT, bbirthisel@aol.com (Bbirthisel) wrote:

:Hi Martin:
:
:>Each time the glob is called, the floppy drive is accessed for a second or
:>two, even though the a: drive isn't the one being looked at by the glob. 
:
:It has occasionally been reported on Perl-Win32-Users that certain
:virus checking software causes this behavior as a side-effect.

Thanks, Bill.  That seems to be the ticket.  I disabled MacAfee Viruscan
3.? and now the script now longer causes the floppy drive accesses.  You
just gotta love the alway straight-forward and obvious nature of all
computer problems and their solutions...don'tcha?

Marty


------------------------------

Date: Sun, 24 Jan 1999 18:48:41 GMT
From: troc@netrus.net (Rocco Caputo)
Subject: Re: CDDB Lookup?
Message-Id: <slrn7amql2.kj.troc@netrus.net>

On Fri, 22 Jan 1999 10:52:38 -0500, Ketan Patel \
<ketanp@BLAHNOSPAMBLAHxwebdesign.com> wrote:
>Is there any way to get information on a CD from a CDDB server based on
>the UPC # (example: 2438-40861-2) via perl?

As far as I know, the CDDB doesn't support UPC lookup.  Let me know if
I'm wrong, and I'll add it to the CDDB module.

-- Rocco Caputo / troc@netrus.net


------------------------------

Date: Sun, 24 Jan 1999 11:54:44 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: CGI.pm and Redirection question
Message-Id: <fl_aggie-2401991154440001@aggie.coaps.fsu.edu>

In article <36AA9756.882949F1@bellsouth.net>, Steve Miles
<nsurfer@bellsouth.net> wrote:

+ print header;
+ 
+ Then, in one of the subroutines I'm using later on I want to redirect
+ the user so I put this:
+ print $query->redirect(-location=>'http://www.yahoo.com');
+ exit;
+ 
+ The problem is that the browser just "prints" the redirection and
+ doesn't send the user on to the site.

Then don't 'print header;'. According to CGI.pm:

          header() returns the Content-type: header.  You can provide
          your own MIME type if you choose, otherwise it defaults to
          text/html.

So, yeah, the browser does the right thing. Redirection works much better
_without_ a content header...

James


------------------------------

Date: 24 Jan 1999 15:11:33 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Do you know a good Perl debugger free ?
Message-Id: <83d844hiay.fsf@vcpc.univie.ac.at>

Re: Do you know a good Perl debugger free ?, Jean
<jean@spirituel.com> said:

Jean> Do you know a good Perl debugger free ?

Ahem, it's built-in: perl -d

(perldoc perldebug)

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


------------------------------

Date: Sun, 24 Jan 1999 14:39:29 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Do you know a good Perl debugger free ?
Message-Id: <slrn7ambuk.i0.dragons@Server.Network>

On 24 Jan 1999 13:31:59 GMT, in article <<78f7cf$idu$1@front3.grolier.fr>>,
Jean Carfantan <jean@spirituel.com> wrote:
=> Do you know a good Perl debugger free ?

You are in luck!

One of the BEST Perl debuggers is very free.

So free, in fact, it comes bundled with Perl!

:-)

Try:

perl -d script

And then:

Loading DB routines from perl5db.pl version 1.0401
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   1
  DB<1>
  
Type |h for help (the | pipes it through a pager).

=> Thank you

HTH!

=> Jean Carfantan

--Matthew


------------------------------

Date: 24 Jan 1999 17:42:22 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: comdog@computerdog.com (brian d foy)
Subject: Re: Easy way to grep all combinations of array subscripts?
Message-Id: <m3g19062s1.fsf@joshua.panix.com>

comdog@computerdog.com (brian d foy) writes:

>       $words{$temp} .= "$word\0"

Or even
   
    push @{$words{$temp}}, $word;

The idea you describe, brian, is at the heart of many anagramming
algorithms, and I've used something like it in a Java version of
Boggle that I scraped together.

> two books that go into this sort of stuff in great
> detail are Programming Pearls by Jon Bentley (notice a
> similarity to another title? :) 

I can't believe I never thought of that.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Sun, 24 Jan 1999 12:02:08 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: encryption question (quickie)
Message-Id: <fl_aggie-2401991202080001@aggie.coaps.fsu.edu>

In article <36AA3B5C.B2894202@tiac.net>, phil@1918.com wrote:

+ I was hacking a little at their script, and not having much success, so
+ here I am, throwing myself on the mercy of this newsgroup.

I'm not sure which would be worse...my poking fun at you, or providing
a possible (untested!) solution, and letting you say a silent 'D0H!' :)

+ sub encrypt_password {
+ }

+ I have text files in a form like this to encrypt: (first is user id,
+ second is unencrypted password)
+ 6930164,6690966

+ I know this is about a six line hack, but for some reason, I'm brain
+ dead. My ultimate goal is to read the text file, encrypt the passwords
+ (the user id's actually will remain UNencrypted), and spit out the user
+ id and the new encrypted password into the .htpasswd file as
+ user_id:encrypted_password

open(PLAIN,'plain_text.passwd') or die $!;
open(ENCRY,">encrypt.passwd") or die $!;
while(<PLAIN>) {
   chomp;
   ($user_id,$passwd)=split /,/;
   $encrypt=&encrypt_passwd($passwd);
   print ENCRY "$user_id:$encrypt\n";
}
close(PLAIN);
close(ENCRY);

James


------------------------------

Date: Sun, 24 Jan 1999 17:15:35 +0100
From: "Nima Mortazavi" <nima.mortazavi@NO_SPAMallgon.se>
Subject: File Upload (Again :-) )
Message-Id: <78fgv8$n99$1@zingo.tninet.se>

Hi

Has some one here try file upload function in Cgi.pm
with BINARY file in IIS/NT inviroment ?

My code works fine with text file, but not with any other binary format :


=====================
use CGI ;
use CGI::Carp qw/fatalsToBrowser/;


$query = new CGI;
$file_name = $query->param('filer');

binmode FH;
open (OUTFILE,">/temp/nima.exe");

undef $BytesRead;
undef $Buffer;
while ($Bytes = read($file_name,$Buffer,1024)) {
  $BytesRead += $Bytes;
  print OUTFILE $Buffer;
}
close($file_name);
close(OUTFILE);
exit ;
=============================



--
Regards,
  Nima Mortazavi
------------------------------------------------------
Please remove NO_SPAM to reply





------------------------------

Date: 24 Jan 1999 17:55:56 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Nima Mortazavi" <nima.mortazavi@allgon.se>
Subject: Re: File Upload (Again :-) )
Message-Id: <m3d844625f.fsf@joshua.panix.com>

"Nima Mortazavi" <nima.mortazavi@allgon.se> writes:

> binmode FH;
> open (OUTFILE,">/temp/nima.exe");

Here you call binmode() on a filehandle that doesn't appear anywhere
else in your program, and then you open a file on another filehandle,
and never check to see whether the open was successful.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 24 Jan 1999 10:02:20 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78fcls$ogd$1@panix.com>

In <78b40v$pkn$2@client2.news.psi.net> abigail@fnx.com (Abigail) writes:

>Doesn't HP ship perl4 by default? And doesn't RedHat come with some
>form of Perl?

RedHat does come with a perl5 distribution...

-- 
Clay Irving
clay@panix.com


------------------------------

Date: 24 Jan 1999 07:19:48 PST
From: "Phlip" <address@web.page>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78fdmk$pve@chronicle.concentric.net>

Clay Irving escribis:
>In <78b40v$pkn$2@client2.news.psi.net> abigail@fnx.com (Abigail)
writes:
>
>>Doesn't HP ship perl4 by default? And doesn't RedHat come with some
>>form of Perl?
>
>RedHat does come with a perl5 distribution...

So does Caldera's OpenLinux (essentially because it's downstream from
RedHat).

New question: How many _Linuces_ out there use Perl for something??

--
 Phlip at politizen dot com                  (address munged)
======= http://users.deltanet.com/~tegan/home.html =======





------------------------------

Date: 24 Jan 1999 16:58:27 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78fjfj$jte@fidoii.cc.Lehigh.EDU>

Eugene Sotirescu <eugene@snailgem.org> wrote:
> Kent Perrier wrote:
>> 
>> "Phlip" <address@web.page> writes:
>> 
>> > Newsgroupies
>> >
>> > Ever since Linux got me (not the other way around), I have observed
>> > that
>> > Perl is as close to an OS component as makes no difference.
>> >
>> > Is anyone out there running a Unix with no Perl installed?
>> 
>> I don't think that there is a commercial UNIX on the market today that
>> ships and installes perl by default.

IRIX does ...

>> 
>> Kent

> If by "commercial" you mean closed-source, you're probably right. But
> both Caldera and RedHat sell their Linux distros with Perl as part of
> the installation (Debian does too, but that might not be "commercial"
> enough).

> -- 

> Eugene

>  "I have an Apache Web Server that uses CGI forms written in COBOL."
>  							Post in clpm

-- 
--
Stephen.O.Lidie@Lehigh.EDU
Lehigh University Computing Center, USA


------------------------------

Date: Sun, 24 Jan 1999 13:48:13 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: How to insert newline break into a long string
Message-Id: <uWJq2.298$WR1.3859@nntp1.nac.net>

Abraham Grief wrote in message ...
:Try adding this:
:$content =~ s/(.{0,70}) /$1\n/g;
:Adjust the 70 to however long you want the maximum length of a line to be,
:provided
:that there are no words longer than the length of the line.


We might want to also match the end of the line as well or we have the last
word on a line all by itself.

$content =~ s/(.{0,70})( |$)/$1\n/g;

There is also the issue of new lines, tabs, multiple spaces, etc..

I would look into the Text:Wrap or Text::Format modules.

HTH

AmD




------------------------------

Date: Sun, 24 Jan 1999 13:48:21 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: How to insert newline break into a long string
Message-Id: <BWJq2.299$WR1.3651@nntp1.nac.net>

Sun Qinghe wrote in message ...
:Hi everyone,
:I have a very long string say 1000 characters called $content. If I
:want send it to a friend like:
:print <<Mail;
:$content
:Mail
:It will be a very long line in the message. I want to insert newline
:break into this long string at certain interval. Could you give me
:a hint ?
:Thanks,
:Sun

I would look into the Text:Wrap or Text::Format modules.  e.g.:

#!/usr/local/bin/perl -w
use strict;
use Text::Wrap qw(wrap $columns);;
$columns = 70;

HTH

AmD




------------------------------

Date: Sun, 24 Jan 1999 17:49:33 GMT
From: miko@idocs.com
Subject: Re: locking file for updating
Message-Id: <78fmfb$1i6$1@nnrp1.dejanews.com>

In article <m367a00z0v.fsf@joshua.panix.com>, Jonathan Feinberg
<jdf@pobox.com> wrote:

>
> Unless I misunderstand your post, what you want is a shared lock.  The
> sharing processes request a shared lock with
>
>     use Fcntl ':flock';
>     flock(FH, LOCK_SH) || die ...
>
> while the janitor process requests an exclusive lock with
>
>     flock(FH, LOCK_EX) || die...

That sounds like what I'm looking for.  I will experiment with it. Thanks!

Your name looked familiar, and searching through my archives I see that
you helped me last time I posted to comp.lang.perl.misc.  You are indeed
a very helpful person.  :-)

-miko

--
Miko O'Sullivan
Author of The Idocs Guide to HTML
http://www.idocs.com/tags/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Sun, 24 Jan 1999 09:09:26 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Loop + rand
Message-Id: <gRFq2.223$WR1.3589@nntp1.nac.net>

Cim wrote in message <36ab1daf.3148007@news.online.ee>...
:I have an array.
:I take a random element from that array,
:Open a file and check if a condition is true. If true it should get
:another element from that array.
:I made a loop and it works fine, but how to check that the next
:element taken from the array is not any of the ones previously already
:checked. I need to do it fast. I think if I make another array
:(elements checked) and then check if current random element is already
:in @elements_checked it will not be very fast.
:
:the number of elements at @array will probably be less than 10.


How interesting, the answer was in todays daily perlfaq from
http://yoak.com/daily_perl/

The gist of the answer is: Use a hash.

HTH

AmD

FAQ follows:

Question:
How can I tell whether a list or array contains a certain element?

    Hearing the word "in" is an *in*dication that you probably should
    have used a hash, not a list or array, to store your data. Hashes
    are designed to answer this question quickly and efficiently.
    Arrays aren't.

    That being said, there are several ways to approach this. If you
    are going to make this query many times over arbitrary string
    values, the fastest way is probably to invert the original array
    and keep an associative array lying about whose keys are the first
    array's values.

        @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
        undef %is_blue;
        for (@blues) { $is_blue{$_} = 1 }

    Now you can check whether $is_blue{$some_color}. It might have been
    a good idea to keep the blues all in a hash in the first place.

    If the values are all small integers, you could use a simple
    indexed array. This kind of an array will take up less space:

        @primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31);
        undef @is_tiny_prime;
        for (@primes) { $is_tiny_prime[$_] = 1; }

    Now you check whether $is_tiny_prime[$some_number].

    If the values in question are integers instead of strings, you can
    save quite a lot of space by using bit strings instead:

        @articles = ( 1..10, 150..2000, 2017 );
        undef $read;
        for (@articles) { vec($read,$_,1) = 1 }

    Now check whether `vec($read,$n,1)' is true for some `$n'.

    Please do not use

        $is_there = grep $_ eq $whatever, @array;

    or worse yet

        $is_there = grep /$whatever/, @array;

    These are slow (checks every element even if the first matches),
    inefficient (same reason), and potentially buggy (what if there are
    regexp characters in $whatever?).



:
:all help appreciated. thanks.




------------------------------

Date: Sun, 24 Jan 1999 14:37:07 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Loop + rand
Message-Id: <slrn7ambq5.i0.dragons@Server.Network>

On Sun, 24 Jan 1999 13:26:06 GMT, in article <36ab1daf.3148007@news.online.ee>,
Cim <cim@online.ee> wrote:
[wants to take an element out of an array on each run of a loop, without
 duplication]

Suffle the array and store it somewhere.

>From the faq:

sub fisher_yates_shuffle {
	my $array = shift;
	my $i;
	for ($i = @$array; --$i; ) {
		my $j = int rand ($i+1);
		next if $i == $j;
		@$array[$i,$j] = @$array[$j,$i];
	}
}

Or:

@new = ();
@old = 1 .. 10;  # just a demo
while (@old) {
	push(@new, splice(@old, rand @old, 1));
}
							
which is less efficient, but that wouldn't matter for a small array (like
your 10 element one).

Then in your loop shift off a value from the shuffled array.

=> all help appreciated. thanks.

HTH!

--Matthew


------------------------------

Date: Sun, 24 Jan 1999 13:57:34 -0500
From: JS <js148@hotmail.com>
Subject: Re: Need script for .htpasswd file
Message-Id: <36AB6D1E.44C3190C@hotmail.com>

Thanks for you advice and I don't want to appear too dumb but ... don't
these assume I have some sort of access to the server? My web site is
hosted remotely and the only access I have is via FTP. Don't even have a
Unix shell but would readily move my site if that would solve my
problem. (Would it?).

The reason I mentioned cgi is because I can run cgi scripts from my web
pages and that way I could read and right the text files. Since these
tend to be written in perl, I thought this might be a good forum to
continue my search. I guess I should have been a little more explicit.
So ... is there a script out there, that presumably uses the unix
crypt() function, that does what I described.

Thanks again ...

Jane


------------------------------

Date: 24 Jan 1999 18:07:42 GMT
From: "Michael Hvrmann" <michael@mismatch.com>
Subject: Re: perl bug with substitution via subroutine?
Message-Id: <78fnhe$3tk$1@goof.de.uu.net>


Rick Delaney <rick.delaney@home.com> schrieb in Nachricht
36AA413F.BAED5C37@home.com...///
>[posted & mailed]
>
>> What's up? Is there a bug in perl? Or is there some point that I missed
>> about $1 and friends on the one hand and @_ on the other?
>
>The latter.
>
>perldoc perlsub
>
>To fix:
>
>    s/foo(bar)/&handler("$1")/e;
>

Many thanks for pointing this out -- although the quotes around $1 come as a
bit of a surprise to me: On page 257f. in Mastering Regular Expressions, $1
is always used "naked" ... but as long as there's at least one way to do it,
I can do without any other ways ;-)





------------------------------

Date: Sun, 24 Jan 1999 12:14:54 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism
Message-Id: <fl_aggie-2401991214540001@aggie.coaps.fsu.edu>

In article <slrn7aisnh.pa1.dformosa@godzilla.zeta.org.au>,
dformosa@zeta.org.au (David Formosa (aka ? the Platypus)) wrote:

+ In article <78b8n4$uo3$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:
+ [...]
+ 
+ >I am only pointing out it's flaws as a general-purpose language.
+ >I would rather see a new language than a fixed Perl.
+ >
+ >BTW, why is it so important to have "more than one way"
+ >to write an IF statement? Variety || die?
+ 
+ Because we are not all the same people, because people like to express
+ things in diffrent ways.  Because they wish to emphasise diffrent points.

Because it allows you to express beauty in your code? topmind would likely
ban Perl Poetry.

James


------------------------------

Date: Sun, 24 Jan 1999 12:23:50 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism
Message-Id: <fl_aggie-2401991223510001@aggie.coaps.fsu.edu>

In article <78bb49$p3$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:

+ In article <78a4cl$h97$2@newshost.oracle.co.uk>,
+   dherriot@uk.oracle.com (Des Herriott) wrote:

+ > It's possible to write unmaintainable code in any language.
+ 
+ If I hear this flippen' MYTH

Proof, please.

+ stated one more time, I am going to
+ have Norton classify Perl as a virus.
+ 
+ ALL
+ LANGUAGES
+ ARE
+ NOT
+ EQUALLY
+ ABUSABLE
+ !!!!!!!

I believe the claim is "unmaintainable code", which is the ultimate
abuse. 

+ I am not going to explain it again.

Show me a language that makes the programmer use _useful_ variable names.
Show me a language that makes the programmer use subroutines and functions.
Show me a language that makes the programmer write comments as he goes along.
Show me a language that makes the programmer write a manual.

James


------------------------------

Date: Sun, 24 Jan 1999 15:48:23 GMT
From: ps258@hotmail.com
Subject: Re: Perl uses in NT
Message-Id: <78ffc5$soq$1@nnrp1.dejanews.com>

In article <36A8136B.2BD37546@patriot.net>,
  keydet89@yahoo.com wrote:
>
>
> > > > Mike wrote in message <773m45$dt0$1@nnrp03.primenet.com>...
> > > > >Hi, I'm new to the Perl world. My boss, a unix administrator,
suggested I
> > > > >learn some Perl and apply it to my NT administration. Could anyone
show me
> > > > >where I could find some good examples or situations where I could use
Perl
> > > > >in NT?
>
> - MD5 checksums
> - EventLogging...both generating and reading/archiving
> - Security assessment tools
> - Port Listener...waiting for skript kiddies to come looking for BO and NetBus
>
> I have toyed with writing a small daemon for workstations and running them
> as a service, a la port 15 on VAX/VMS systems.  If you block the port you
> use at the firewall, and are on a relatively small LAN with trusted users,
> this shouldn't be a problem...

I'm writing a network documentation script that's run from the schedule
service. It connects to every NT workstation and server in the domain and
gathers statistics and configuration information from each and logs it to a
set of text files. It also makes any configuration changes that I require,
and will (when I get around to it) email me with problems found in event
logs, predictions on when disks will run out of space, attemtps to crack the
admin password, changes to the membership of certain domain groups, additions
to the domain, groups, users, and machines. etc...

I want it to be something that is able to notify me when anything odd has
happened, or is about to happen so that I can be on top of things before they
become a problem. I also want to be able to findout what services or shares a
machine had at any time in its history.

There is a list for such things hosted by active state. Anyone thinking of
using perl for NT admin tasks will find it an invaluable resource. have a look
at http://www.activestate.com

Cheers,
Peter

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Sun, 24 Jan 1999 17:57:57 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Problem with dbm hash
Message-Id: <ebohlmanF62sKL.GBt@netcom.com>

Steve <root@coredcs.com> wrote:

: I'm having a problem with a hash database file.  I need to store
: multiple values in one key and thus I'm using an array(per the Perl
: Cookbook).  My problem is in syntax for viewing the data once entered.

: I can input the values into the hash and they seem to be correct and
: getting into the hash array variable.  However when, on the next run,
: I try to view any of the previously entered data, nothing comes up.  I
: _know_ I am doing something syntactically and simply wrong.

Nope, your problem is that tied-hash database files can only store 
strings as values, but you need to store complex data structures.  The 
solution is to use something like MLDBM, which will "serialize" your data 
structures when they're stored and "unserialize" them when they're 
retrieved.  You might want to read the chapter on persistence in 
_Advanced Perl Programming_ for other ideas.



------------------------------

Date: Sun, 24 Jan 1999 15:30:12 GMT
From: Steve Vertigan <vertigan@iinet.net.au>
Subject: Re: Safely editing /etc/passwd.
Message-Id: <36ab38a6.16878200@news.omen.com.au>

jbritain@home.com wrote thus:


>1. Copy the file, and work on the copy, not the original, make a
>second copy, and save it to a date/time serialized file for backup.

Is there any particular advantage to working on a backup?  I like the idea
of a serialized backup but the way I'd do it at the moment involves only two
operations on /etc/passwd.
1) Read.
2) mv /etc/passwd2 /etc/passwd
2 will need to be performed in anycase but I can't see what can go wrong
with 1.

>2. Since it's only changing a password, the file character count
>(size) should be exactly the same, and you can in fact "edit in place"
>if the whole file will fit in memory at once.

I must confess I don't understand what "edit in place" means.  Could I be
enlightened? :)  Also I'm hoping to expand this to adding and removing users
so there may be more substantial changes.

>3. either with a cron job, do a weekly wipeout of old backups, (of
>course this will depend upon number of changes/week, etc.) but it
>leave you a fallback position. Save the backups root-owned, mod 0400.

A good idea.

>4. sort the file by UID, before saving it to an intermediate temporary
>passwd file in the destination directory.  chmod the original passwd
>file so that it can be eliminated, and then mv the new passwd.tmp in
>place. chmod the finally written passwd file to 0444, and chown, and
>chgrp it, just for insurance.
>
>5. Consider, that you may need to make the original temporarily
>unavailable to prevent other users from doing simultaneous updates of
>their accounts while the process is running.

I don't think I'll run into this problem as users requests are stored in
individual files, the files are then mv to a processing directory where they
are read and then removed by the cron process.  The program then performs
the actions on the passwd file all in one hit.  I'm assuming that if the
original perl script called from the email alias is writing a file then a
system("mv *") will fail on that file and it will be processed on the next
run.  If I change the normal permissions to 444 then this should stop
someone from accessing it with vi while the script is working.  The only
other thing is to fail to process at all if the files NOT 444, indicating
someone has changed the permissions and is working on the file manually.

>Timing, and sequence is everything, as well as comparison of old and
>new file (byte count, and character difference -- 13 characters) on
>similarly sorted lines.
>
>Another method to use, since the character space is fixed, is copy,
>seek, and replace characters in place in the new copy. -- especially
>for largish files...

I assume that as I may be removing or adding lines from the file which I
neglected to originally mention these won't work?  At any rate thanks for
your backing up and permission suggestions, they've probably saved me from a
possible catastophe :)

Regards,
--Steve



------------------------------

Date: Sun, 24 Jan 1999 15:38:25 GMT
From: ps258@hotmail.com
Subject: searching a binary file
Message-Id: <78fepg$sbm$1@nnrp1.dejanews.com>

Hi all,

I want to do the eqivalent of

find . -name \* -exec grep search_string {} \;

on a system that has neither find nor grep. My script seems to run, but it
isn't finding every occurance. I suspect that it's reaching a ^D or ^Z in the
binary file and just taking it as the eof.

Here's the core code.

open($FH, "$FileName");
while (<$FH>)
{
    if (/\bMain::$searchString\b/i)
    {
        print "$FileNamet\n";
        last;           # found a string, leave now
    }
}
close($FH);

Does anyone have a way to scan a binary file for a string? I think that
porting grep to perl is more than my meagre skills are up to, and may be
deathly slow.

TIA,
Peter

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Sun, 24 Jan 1999 18:09:45 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: searching a binary file
Message-Id: <ebohlmanF62t49.Gyn@netcom.com>

ps258@hotmail.com wrote:
: I want to do the eqivalent of

: find . -name \* -exec grep search_string {} \;

: on a system that has neither find nor grep. My script seems to run, but it
: isn't finding every occurance. I suspect that it's reaching a ^D or ^Z in the
: binary file and just taking it as the eof.

perldoc -f binmode

: Here's the core code.

: open($FH, "$FileName");

It would make a lot of sense to check if you could actually open the 
file and die with a meaningful error message if not.

Filehandle names shouldn't start with '$'.

The quotes are superfluous.
Add:

binmode FH

here.

: while (<$FH>)
: {
:     if (/\bMain::$searchString\b/i)
:     {
:         print "$FileNamet\n";
:         last;           # found a string, leave now
:     }
: }
: close($FH);


------------------------------

Date: Sun, 24 Jan 1999 18:43:33 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: searching a binary file
Message-Id: <ebohlmanF62uoL.Izz@netcom.com>

Eric Bohlman <ebohlman@netcom.com> wrote:
: Add:

: binmode FH

: here.

That should, of course, be:

binmode FH;



------------------------------

Date: Sun, 24 Jan 1999 13:42:50 -0500
From: "The Smiths" <smiths@erols.com>
Subject: Trying to automate FTP
Message-Id: <78fp43$so3$1@winter.news.rcn.net>

I know that I can use NET::FTP, LWP, and other socket related packages to
drive an FTP connection, but I wanted to simply drive the FTP shell command
from a Perl script.   This would be handy for the automation of other
commands as well.

However, I have not succeeded and was wondering if anyone may have an
example.  I can get the first FTP command piped to the program, but
subsequent FTP commands go unrecognized.

I tried system, back ticks, and most recently this:

open (FTP, "|ftp");
print FTP "open ftp.site.com\n";
print FTP "userid\n";
 .
 .
 .


The concept that I am looking for is the ability to stack commands so that
everytime FTP reads from the command line, it pulls the next entry off the
stack.

Thanks,
Tim Smith
CDS Web Services, Inc.




------------------------------

Date: 24 Jan 1999 17:36:33 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Where can I find text parsing samples
Message-Id: <m3iudw631q.fsf@joshua.panix.com>

e_ron.no.spam@netvision.net.il (Ron) writes:

> I am familiar with VB and C so the code looks familiar and easy to
> use.

Yes, it's funny that Larry and Tom have never copped to the role VB
played in the semantics and overall "feel" of Perl.

Smiley.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4736
**************************************

home help back first fref pref prev next nref lref last post