[9445] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3040 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 1 17:07:21 1998

Date: Wed, 1 Jul 98 14:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Jul 1998     Volume: 8 Number: 3040

Today's topics:
    Re: An interesting observation (John Stanley)
    Re: ANNOUNCEMENT: clpa doesn't accept perl announcement lvirden@cas.org
    Re: Associative arrays and LISTS. (Kevin Reid)
    Re: Can't kill telnet process with Comm.pl close_it() r <jay@rgrs.com>
    Re: Dejanews/closed lists/moderated groups/lists [Was:  birgitt@my-dejanews.com
    Re: Dereferencing Anonymous Hash? (Kevin Reid)
    Re: Doublequoting philosophy <cw@dwc.ch>
    Re: html2ps and ghostscript failing <H.Blischke@srz-berlin.de>
        Invalid regexp in grep s_emery@my-dejanews.com
    Re: Invalid regexp in grep (Larry Rosler)
        matching second word in a line <wlemke@iris.nyit.edu>
    Re: matching second word in a line (Josh Kortbein)
    Re: matching second word in a line (Craig Berry)
    Re: matching second word in a line <jason.holland@dial.pipex.com>
        passing a ref to a subroutine, problem with use strict (Allan M. Due)
    Re: Perl Editor for Windows NT ? Grehom@my-dejanews.com
    Re: Perl Script as a NT Service epierre@mail.esiea.fr
    Re: Q: About creating user accounts from web logins (Josh Kortbein)
        Regular expression matech for ( non-fixed number of ()  (Michael Wang)
        setting directory permissions... <alcazar@netcomp.net>
    Re: setting directory permissions... (Matt Knecht)
    Re: SHELL/REGEX GUNSLINGERS NEEDED!!! <maik.hertha@volkswagen.de>
    Re: What a Crappy World (John Stanley)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 1 Jul 1998 20:12:31 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: An interesting observation
Message-Id: <6ne57f$ed3$1@news.NERO.NET>

In article <6ne0ff$tvh$1@cyprus.atlantic.net>,
Chip Salzenberg <chip@mail.atlantic.net> wrote:
>According to stanley@skyking.OCE.ORST.EDU (John Stanley):
>>In article <6n6anv$7r1$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>>>My question last week at <6m7rd5$m7k$1@monet.op.net> went unanswered.
>>>(So far.)
>>
>>My request for ....
>
>Well, you _do_ have to consider the source.

Yes, someone who was trying to write something to benefit the
community. I had no need for code to manage a registration list. 

>While clpm is generous, it does have a memory.

And holds grudges against people who hold opinions that are not
popular. Yes, I know. Excuse me for pointing out that getting answers
depends more on who likes who than on how things are asked.



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

Date: 1 Jul 1998 16:58:06 GMT
From: lvirden@cas.org
Subject: Re: ANNOUNCEMENT: clpa doesn't accept perl announcements!
Message-Id: <6ndpqu$28i$1@srv38s4u.cas.org>


According to Tom Christiansen  <tchrist@mox.perl.com>:
:announcements, or else we need a new moderator.  It can be trivially
:fixed, right now.  We don't need a committee.  We just need someone doing

Well, a temporary work around might be to write a piece of perl code
which produces the types of things you wish mentioned in the announce
newsgroup as output - then submit postings to the newsgroup when the
software is 'updated' to produce the new output.  Of course, it is
only appropriate that a sample of the kind of output one would expect
from the software would be a part of the announcement...


-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Wed, 1 Jul 1998 15:42:16 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Associative arrays and LISTS.
Message-Id: <1dbhlrl.dzfqtb192i20wN@slip166-72-108-122.ny.us.ibm.net>

Bill Oswald <wao@aluxs.micro.lucent.com> wrote:

> I have an associative array and I want it to contain a list.
> How do I create/operate on this array. I've tried:
> 
> $assoc{"foo"} = (); Create an empty list
> $assoc{"foo"} = ($name);
> ...
> foreach $tmp ($assoc{"foo"})
> {
> }
> 
> This works. But I really want
> 
> $assoc{"foo"} = ();
> push ($assoc{"foo"} , $name);
> ...
> foreach $tmp($assoc{"foo"})
> {
> }
> 
> The push would allow me to grow the list that is associated
> with $assoc{"foo"}. How do I assign a list to an associative
> array and how do I use the associative array so that its
> content is considered a list?

Hashes (associative arrays) can only contain scalars.

What you need is a reference to an array.

#!perl -w

%hash = ();

$hash{'temp'} = ['a', 'b'];
$hash{'yerg'} = ['z', 'y'];
# brackets make anonymous array

push @{$hash{'temp'}}, 'c';
$hash{'yerg'}[2] = 'x';

foreach $key (keys %hash) {
  print "$key:\n";
  foreach $value (@{$hash{$key}}) {
    print "  $value\n";
  }
}

__END__

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 01 Jul 1998 15:35:36 -0400
From: Jay Rogers <jay@rgrs.com>
To: Brett Denner <Brett.W.Denner@lmco.com>
Subject: Re: Can't kill telnet process with Comm.pl close_it() routine
Message-Id: <8267hhcqk7.fsf@shell2.shore.net>

Brett Denner <Brett.W.Denner@lmco.com> writes:
> I'm trying to use Net::Telnet and Comm.pl to build a script that
> will log on another computer with telnet, then hand over the telnet 
> session to me so I can work interactively on the other computer.
> I don't like using rlogin because rlogin doesn't propagate much
> of my current session to the other computer (the man page for rlogin
> says that only the TERM variable is propagated).
> 
> I've cobbled together a script using documentation for Net::Telnet
> and Comm.pl, and this is what I have:

 ...

> my $host = new Net::Telnet 
>     (
>     Fhopen     => $pty,
>     Timeout    => 10,
>     Prompt     => "/^\$: \$/",

If possible always use a single quoted string to define a prompt.  For
more info see the Net::Telnet manpage, section "What To Know Before
Using".  Also it's highly unlikely that you really want to anchor the
prompt at the beginning of the read buffer using '^'.  Prompts
generally are the last thing printed.

> Everything works okay, except that when the script is finished there
> are still two telnet sessions remaining (they can be seen with ps).

Well you don't say what kind of machine you're running this on.
Comm.pl doesn't work with all Unices.

> Can anyone suggest ways to improve this script?

 ...

> I have to kill the X window it was run in.

Well if you're using X, why not just use Net::Telnet to login, set the
environment variables you want, and start an xterm displayed on the X
server where you're working?

This will do that:

#!/usr/bin/perl

use strict;

## Module import.
use Net::Telnet ();
use Sys::Hostname qw(hostname);

## Global variables.
$ENV{PATH} =
    "/bin:/usr/bin:/usr/ucb:/usr/bin/X11:/usr/local/bin:/usr/openwin/bin";

## Main program.
{
    my ($remote_host, $username) = @ARGV
        or &usage;
    die "DISPLAY not defined" unless length $ENV{DISPLAY};
    my $passwd = &prompt_user("Password: ");

    ## Determine location of X server.
    if ($ENV{DISPLAY} =~ /^(:|unix:)/) {
        $ENV{DISPLAY} = hostname . ":0.0";
    }
    system "xhost $remote_host >/dev/null";

    ## Connect and login.
    my $t = new Net::Telnet;
    $t->open($remote_host);

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

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

    ## Switch to a known shell, using a known prompt.
    $t->prompt('/MyPrompt> $/');
    $t->errmode("return");

    $t->cmd("exec /usr/bin/env 'PS1=MyPrompt> ' /bin/sh -i")
        or die "login failed to remote host $remote_host";

    ## Set all your environment vars here.
    $t->cmd("DISPLAY='$ENV{DISPLAY}'; export DISPLAY");
    $t->cmd("PATH='$ENV{PATH}'; export PATH");

    ## Start an xterm displayed on the local X server.
    $t->cmd("xterm -T 'xterm \@ $remote_host' -n 'xterm\@$remote_host' &");
    sleep 1;
    $t->print("exit");
    $t->close;

    exit;
} # end main program


sub autoflush {
    select((select($_[0]), $|=1)[$[]);
}


sub prompt_user {
    my($prompt) = @_;

    &autoflush(*STDOUT);
    system "stty -echo";

    print $prompt;
    my $answer = <STDIN>;
    chomp $answer;
    print "\n";

    system "stty echo";

    $answer;
}


sub usage {
    die "usage: $0 remotehost username\n";
} # end sub usage


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

Date: Wed, 01 Jul 1998 20:47:43 GMT
From: birgitt@my-dejanews.com
Subject: Re: Dejanews/closed lists/moderated groups/lists [Was: Re: Is perl5-porters closed to subscription?
Message-Id: <6ne79f$6v5$1@nnrp1.dejanews.com>

In article <fl_aggie-0107981306430001@aggie.coaps.fsu.edu>,
  fl_aggie@thepentagon.com (I R A Aggie) wrote:
by.
> I fear you may be under the impression that clp.misc will
> become moderated if the current proposal passes.

Not so, I got that one. :-)

[snip]

> dejanews only archives newsgroups, not mailing lists, except in cases
> where there is a usenet<->mailing list gateway.

Thanks, that's a point I wasn't aware of.

>
> Where do you get this idea of "democracy"? Usenet is not a democracy,
> it never was, and likely will never be.

Hmm, I know I always have kind of strange ideas. I guess I have
to do some soul searching.

>
> + Who owns dejanews ?
>
> See their web page.
>

Sorry for not doing that the way I should have, shame on me. :-(

>
> + Who pays for dejanews ?
>
> Advertisers.

I don't like that - considering how important the stuff is
they intend/claim/are supposed to do.

But that's nothing for c.l.p.m. So, I stop right now.

Birgitt Funk


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 1 Jul 1998 15:42:14 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Dereferencing Anonymous Hash?
Message-Id: <1dbhlhd.ofglv3kw3d1aN@slip166-72-108-122.ny.us.ibm.net>

John Call <johnc@interactive.ibm.com> wrote:

> I was reading through Effective Perl Programming by Hall & Schwartz this
> weekend and came to this interesting one-liner:
> 
> @uniq = sort keys %{ { map {$_,1} @list } };
> 
> This eliminates all the duplicates from a list. This is all explained
> very well in the book and I can see what it does but have two questions
> about things I am not quite clear on.
> 
> First:
> 
> The second set of {} "..reference to an anonymous hash intialized with
> those values." The first set of {} are "The 'name' of the dereferenced
> hash - suitable as an arguement for keys."
> 
> What I don't know is why the second set of {} couldn't be the arguement
> for keys. Why do I have to dereference the anonymous hash?

Because keys requires a real hash - not a list.

> Second:
> 
> Why does it sort?

So that you don't get the items in 'hash order'.

> Does this destroy the duplicates?

Sorting does not destroy the duplicates.

> I assumed the duplicates would be destroyed just by being assigned as
> keys.

Yes.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Wed, 01 Jul 1998 23:00:23 +0200
From: Christoph Wernli <cw@dwc.ch>
Subject: Re: Doublequoting philosophy
Message-Id: <359AA367.1B4DE8A1@dwc.ch>

Martin Gregory wrote:
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> > A good point is that using '...' consistently when there is no
> > interpolation immediately draws attention to "..." when there *is*
> > (should be) interpolation (or interpretation of escape sequences other
> > than \\ or \').
> >
> > I've switched my null strings from '' to "" though, because it's too easy
> > to eyeball '' as ".
> 
> The only sad thing is that perl-mode (or my version/setup of it)
> doesn't fontify '' strings :-(

And another sad thing is that you end up having to chase the single
quoted strings that you want interpolated after you've changed your code
over and over again, including stuff to be interpolated in
soingle-quoted strings. But I guess that's pure laziness...

-werns


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

Date: Wed, 01 Jul 1998 21:10:42 +0200
From: Helge Blischke <H.Blischke@srz-berlin.de>
Subject: Re: html2ps and ghostscript failing
Message-Id: <359A89B2.268B@srz-berlin.de>

aaron.d.newsome@wdc.com wrote:
> 
> I have been a happy user of both ghostscript and html2ps for some time.
> 
> I recently began using html2ps to generate some database reports from a
> mysql database (using perl scripts to pull the data from database and make
> html, then using html2ps to build a printfile).
> 
> These database reports create very long tables (many pages), but I'm not
> sure if that is the problem since I have successfully used html2ps on html
> that had tables spanning as many as 20 pages!
> 
> Anyway, I am using Aladdin Ghostcript 5.10, and the command line looks
> like this:
> 
> html2ps -D myfile.html > myfile.ps
> 
> pretty simple.
> 
> The error I get when I run this is:
> 
> Error: /rangecheck in --put-- Operand stack:
>    --nostringval-- 12.0 --nostringval-- 31 2 
> ...
> Current allocation mode is local Current file position is 243969
> GS<1>
You should enter 
pstack flush 
at this point to get more readable information on what's
left on the stack.
I presume there is an error in one of the preprocessing steps
(is looks like putting some value into an array with an index
which exceeds the size of the array.

Helge
> 
> Does anyone have any idea of what any of this means or how I would go
> about fixing it.
> 
> I would really appreciate any help.
> 
> Thanks, Aaron Newsome
> aaron.d.newsome@wdc.com
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

-- 
H.Blischke@srz-berlin.de
H.Blischke@srz-berlin.com
H.Blischke@acm.org


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

Date: Wed, 01 Jul 1998 20:10:03 GMT
From: s_emery@my-dejanews.com
Subject: Invalid regexp in grep
Message-Id: <6ne52q$4it$1@nnrp1.dejanews.com>

I can't seem to grep a certain array because I get an error of invalid
regexp.

This is the idea of the programming:

@a = (1 ,2, 5, 22, 84, 129, 205);

@b = grep (/[7-176]/, @a);

Which doesn't work because 176 is out of range - the highest number
allowed is 99. This is too bad, I hope this is fixed in the future
versions of Perl.

Greping is a whole lot faster than attempting to make a for loop.
If there is a way around this please tell me.

Thanks,

Emery Szasz

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 1 Jul 1998 13:52:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Invalid regexp in grep
Message-Id: <MPG.10044159bcda5249896e0@nntp.hpl.hp.com>

In article <6ne52q$4it$1@nnrp1.dejanews.com> on Wed, 01 Jul 1998 20:10:03 
GMT, s_emery@my-dejanews.com <s_emery@my-dejanews.com> says...
> I can't seem to grep a certain array because I get an error of invalid
> regexp.
> 
> This is the idea of the programming:
> 
> @a = (1 ,2, 5, 22, 84, 129, 205);
> 
> @b = grep (/[7-176]/, @a);
> 
> Which doesn't work because 176 is out of range - the highest number
> allowed is 99. This is too bad, I hope this is fixed in the future
> versions of Perl.

You misunderstanmd the use of square brackets in regexes.  What you have 
requested is a match against a single character in the range of 
characters between 7 and 1, or a 7, or a 6.  The perl compiler complains 
about the invalid range, and refuses to compile the regex.

When you say the hishest number allowed is 99, what you were really 
matching against was a single character in the range of characters 
between 7 and 9, or a 9.  This is not what you wanted.

You should not use a regex for this problem.  Try the following:

@b  = grep 7 <= $_ && $_ <= 176, @a;

When you want to compare numbers, use them as numbers, not as strings.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 01 Jul 1998 14:08:04 +0100
From: William Lemke <wlemke@iris.nyit.edu>
Subject: matching second word in a line
Message-Id: <359A34B4.F3E6978@iris.nyit.edu>

I'm trying to match the second word in a line, I
can't figure out how.




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

Date: 1 Jul 1998 20:17:34 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: matching second word in a line
Message-Id: <6ne5gu$73g$1@news.iastate.edu>

William Lemke (wlemke@iris.nyit.edu) wrote:
: I'm trying to match the second word in a line, I
: can't figure out how.

You could split the line at spaces, as in:

$line = "This is a line with multiple words.";

$second = (split(' ', $line))[1];

print "$second\n";


or try something like

if ($line =~ /\w+\s*(\w+)/) {
    print "$1\n";
}

Try reading the perlre manpage.

Josh

--

_________________________________________________________
I do not trust your bitch.
	- Frederich Nietzche, in _Also Sprach Zarathustra_



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

Date: 1 Jul 1998 20:49:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: matching second word in a line
Message-Id: <6ne7cr$jbs$1@marina.cinenet.net>

Josh Kortbein (kortbein@iastate.edu) wrote:
: William Lemke (wlemke@iris.nyit.edu) wrote:
: : I'm trying to match the second word in a line, I
: : can't figure out how.
: 
: You could split the line at spaces, as in:
: 
: $line = "This is a line with multiple words.";
: 
: $second = (split(' ', $line))[1];
: 
: print "$second\n";

Or similarly, match each word ont the line and take the second one:

  $second = ($line =~ /(\w+)/g)[1];

This handles non-word, non-space characters differently, of course.

: or try something like
: 
: if ($line =~ /\w+\s*(\w+)/) {
:     print "$1\n";
: }

Probably \W would be better than \s; otherwise "Hi, I have a few words"
will fail rather than succeeding and setting $1 to 'I'.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 01 Jul 1998 21:30:35 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: William Lemke <wlemke@iris.nyit.edu>
Subject: Re: matching second word in a line
Message-Id: <359AAA7B.B242F2FC@dial.pipex.com>

This is a multi-part message in MIME format.
--------------BF899D25F6740ECB3ABFF0DC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

William Lemke wrote:
> 
> I'm trying to match the second word in a line, I
> can't figure out how.

Hello,

Try a quick hack like this:


	$string = "Hello World!";
	$string =~ m/^[^ ]+ ([\w]+)/;
	print "$1\n";


Where $1 is the first successful pattern match. There are other better
ways of doing this, I'm sure.


Bye!

-- 
sub jasonHolland {
    my %hash = ( website =>
"http://dspace.dial.pipex.com/jason.holland/",
                 email   => "jason.holland@dial.pipex.com" );
}
--------------BF899D25F6740ECB3ABFF0DC
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jason Holland
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Jason Holland
n:              Holland;Jason
email;internet: jason.holland@dial.pipex.com
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------BF899D25F6740ECB3ABFF0DC--



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

Date: 1 Jul 1998 20:23:17 GMT
From: due@murray.fordham.edu (Allan M. Due)
Subject: passing a ref to a subroutine, problem with use strict
Message-Id: <6ne5rl$9qd$0@206.165.146.67>

Hi Folks,

     I've been working away at learning Perl and I wanted to be able to 
search an array using any variable utilizing just one subroutine.  I 
wrote a script that would achieve the results I wanted, but when I tried 
to clean it up using use strict I ran into problems.  Below is a 
stripped down version that illustrates my problem. You can change the 
search_on and search_for variables and it works fine.  But if you 
include use strict you have to include a my in front of the
($animal,$color,$name) = split(/\,/,$I);
line and when you do that you receive the error message:
Can't use string ("color") as a SCALAR ref while "strict refs" in use
If you comment out use strict but leave the my in place the script no 
longer works correctly.

    Clearly, I am missing something.  I am also sure there are better 
ways to do this <g>.  If someone could direct me to the correct 
references and/or tell me how to better attain my goal I would 
appreciate it.  
     As a last confession, the if statement sort of bubbled up out of my 
subconscious.  I was pleased to see that it worked, but I am not really 
sure why it works so direction/instruction there would be appreciated as 
well.  
     Thanks,

AmD 

PS I sometimes get weird spacing when I cut and paste from my text 
editor to the newsgroup software.  My apologies in advance if this post 
illustrates the weirdness.
-- 
Allan M. Due
Due@Murray.Fordham.edu

The beginning of wisdom is the definitions of terms.
- Socrates

----------------8<------------------------------- 
#!/usr/local/bin/perl
#use strict;

my @data = ('dog,black,sparky',
            'cat,black,socks',
            'dog,white,fido');

my $search_on = "color";
my $search_for = "bl";

&search (\$search_on,\$search_for,\@data);

foreach (@data) {
    print "$_\n";
}

sub search {
    my $i;
    my $ref;
    my @keep_array;
    my($key_ref,$search_ref,$search_array_ref)= @_;
    my(@search_array) = @$search_array_ref;
    foreach $i (@search_array) {
        ($animal,$color,$name) = split(/\,/,$i);
	 if ($$$key_ref =~ /$$search_ref/i) {
	 $ref++; 
	 push (@keep_array, $i);
	 }
    }
    @$search_array_ref = @keep_array;
}
    


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

Date: Wed, 01 Jul 1998 18:46:24 GMT
From: Grehom@my-dejanews.com
Subject: Re: Perl Editor for Windows NT ?
Message-Id: <6ne05v$u7h$1@nnrp1.dejanews.com>

In article <6n7p4d$ga8$1@news02.btx.dtag.de>,
  PBUhauck@t-online.de (Uwe Hauck) wrote:
>
> Hello !
> Does anyone know of any Editor (best would be freeware)
> for Windows NT that understands Perl Syntax ?

I use an editor in windows 95 called Lemmy - it has syntax highlighting for
Perl and a couple of other languages.  I only paid $20 after the free trial
period of a month - look in www.softwareonline.org for it.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 01 Jul 1998 18:56:33 GMT
From: epierre@mail.esiea.fr
Subject: Re: Perl Script as a NT Service
Message-Id: <6ne0p0$vre$1@nnrp1.dejanews.com>

In article <6n8qc1$r7h$1@nnrp1.dejanews.com>,
  scythale@my-dejanews.com wrote:
>
> Hi,
>
> 	I've worked hard on a Perl script that chech directories, as well as network
> mapped.
>
> 	As a DOS shell or an explorer execution it goes well.
>
> 	As soon as I install it as a NT Service to launch it every 10 mn, I have an
> erratical behaviour:
>
> 		- impossible to access mapped drives
>
> 		- impossible to send emails
>
> 	As far as I know, the service is launches as the account system, that doesn't
> really exist.
>

I've managed to resolv the problem, but some others appeared:

	- how to mount a share with Win32::AddConnection

	- I can add a NT service, and say to use a specified user, but I
don't know how to give its password, so the service cannot be started ...

Need some help. TIA

-= Emmanuel PIERRE                               epierre@mail.esiea.fr =-
http://www.esiea.fr/public_html/Emmanuel.PIERRE      http://www.esiea.fr
http://www.e-presence.esiea.fr                    http://www.apr-job.com

               L I N U X - WebMaster - SysAdm - Perl Guru

http://www.esiea.fr:8080  Intranet Inter ESIEA  http://hp1.esiea.fr:2001
                                    http://dvorak.esiea-ouest.fr:2001


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 1 Jul 1998 18:43:24 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Q: About creating user accounts from web logins
Message-Id: <6ne00c$3b2$1@news.iastate.edu>

fgump@my-dejanews.com wrote:
: Please don't treat me like an idiot.  I've read everything, FAQ's, USENET
: postings, and books.  I hate clogged newsgroups just as much as the next
: person.  This IS my last resort.

: If you take the time to READ PAST THE FIRST PARAGRAPH OF MY ORIGINAL POSTING,
: you'll see that I'm not asking about how to create password protected
: directories, but rather something else more complicated.  I was just shedding
: a little light on the subject to make it easier to understand.  You rashly
: misinterpreted the first paragraph.  Notice how the first two words are "It
: is" and not "Is it".

Regardless of how complicated you think your problem is, it still
doesn't have anything special to do with Perl. You even brought up
possible answers, involving cookies, environment variables, etc., in
your original post. So why didn't you seek out a newsgroup that deals
with those?

Josh

--

_________________________________________________________
I do not trust your bitch.
	- Frederich Nietzche, in _Also Sprach Zarathustra_



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

Date: 1 Jul 1998 20:06:23 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Regular expression matech for ( non-fixed number of () pairs )?
Message-Id: <6ne4rv$d2q$1@news.ml.com>

I want to take out 
SID_LIST_listener_name=( ...
                       )
from the following text. Can perl/shell/sed/awk do this? Or I need to
resort to lex/yacc? Thanks.

What I want to do is to find SID_NAME=SID, but I do not want to find
it from wrong place. Please note the following text is of free format
following some rules. 

other similar stuff in listener.ora
SID_LIST_listener_name=[(SID_LIST=]
                                (SID_DESC=
                                   (GLOBAL_DBNAME=global_database_name)
                                   (SID_NAME=SID)
                                   (operating_system_specific_
                                     string=db_location)
                                )
                                [(SID_DESC=
                                   (GLOBAL_DBNAME=global_database_name)
                                   (SID_NAME=SID)
                                   (operating_system_specific_
                                    string=db_location)
                                )]
                            [)]
other similar stuff in listener.ora


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

Date: Wed, 1 Jul 1998 14:33:23 -0500
From: "Ric Alcazar" <alcazar@netcomp.net>
Subject: setting directory permissions...
Message-Id: <e1r6NcSp9GA.243@upnetnews05>

    Hello all,

    when I create a new directory:

    mkdir($directory, $permissions);

    and try to set the permissions... it never gets set correctly...
    sometimes I try to set $permissions = '0700', but that doesn't seem to
work... instead... I get a different permissions assigned... can anyone
help?

    Ric




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

Date: Wed, 01 Jul 1998 19:59:41 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: setting directory permissions...
Message-Id: <Nywm1.22$Du.237553@news2.voicenet.com>

Ric Alcazar <alcazar@netcomp.net> wrote:
>    mkdir($directory, $permissions);
>
>    and try to set the permissions... it never gets set correctly...
>    sometimes I try to set $permissions = '0700', but that doesn't seem to
>work... instead... I get a different permissions assigned... can anyone
>help?

Hmmm... I'm not sure.  Let me check 'perldoc -f mkdir'
	
 Creates the directory specified by FILENAME, with permissions specified
 by MODE (as modified by umask).  If it succeeds it returns 1, otherwise
 it returns 0 and sets C<$!> (errno).

That doesn't seem to be much help.  I wonder what it means by umask... I
better check 'perldoc -f umask'!

 ...
 umask is a number, usually given in octal; it is I<not> a string of octal
 digits.  See also L</oct>, if all you have is a string.

Hmmm... looks like I need to check 'perldoc -f oct' next.

 ...
 This function is commonly used when
 a string such as "644" needs to be converted into a file mode
 ...

Looks like you need:

mkdir($directory, oct($permissions)) or die "Can't mkdir $directory: $!";

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Wed, 01 Jul 1998 19:25:01 +0200
From: Maik HERTHA <maik.hertha@volkswagen.de>
To: Rholder@sispost1.bis.adp.com
Subject: Re: SHELL/REGEX GUNSLINGERS NEEDED!!!
Message-Id: <359A70ED.E2C158B6@volkswagen.de>


--------------A70B3AE2AE339F648A6DB844
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Rholder@sispost1.bis.adp.com wrote:

> I want to store regular expressions in one file, and then use a
> shell script to read them into a shell variable within a "for" loop,
> and then feed the expression into egrep via the shell variable.
>
> I'm doing this under Solaris 2.5.1.
>
> Here is my script:
>
>   #!/usr/bin/ksh -x
>   #
>   # pidfinder -- find the PID of a process given a regex that will
>   #              pluck that process from the output of ps -eo args,pid
>   #
>   for REGEX in `(cat /usr/local/scripts/pregex)`
>   do
>         ps -eo pid,args | egrep -v egrep | egrep $REGEX | awk '{print $1}'
>   done
>   # END OF SCRIPT
>
> ....and here is what is in the file /usr/local/scripts/pregex:
>
> '(dataserver).*(miler)+'
> '(dataserver).*(citys)+'
> '(dataserver).*(demo)+'
>
> Here is what the lines I'm searching for look like:
>
> $ ps -eo pid,args | egrep dataserver
>   970 /opt/sybase/bin/dataserver -d/db/mstr/miler_mstr.0 -smiler
> 18042 egrep dataserver
>   959 /opt/sybase/bin/dataserver -d/db/mstr/demo_mstr.0 -sdemo
>   948 /opt/sybase/bin/dataserver -d/db/mstr/citys_mstr.0 -scitys
>
> ....I use the "ps -eo pid,args" rather than "ps -ef" or something more
> usual so that I can see more of the sybase arguments.  We have three
> dataservers running on this machine, and I need to be able to grab the
> line from "ps" for each one, as differentiated by the "miler", "citys"
> and "demo" part of the expression.
>
> These regular expressions work when I type them in at the shell
> prompt, like this:
>
>   ps -eo pid,args | egrep '(dataserver).*(miler)+' | awk '{print $1}'
>
> ....this gives me the correct PID.  But they don't work when plugged in
> via the $REGEX variable in the shell script...
>
> It seems to me that the meaning of the quotes is changing when they are
> in the content of the $REGEX shell variable, but I don't understand how
> and I'm starting to run out of ideas...
>
> I don't want to write a long, ugly script with lots of individual egrep
> statements.  Is there a way to do this, or should I try an entirely
> different approach?  I'm just starting to learn Perl, and I have a
> feeling this is easier to do in Perl, but I need to get this script done,
> like, yesterday...
>
> THANKS FOR ANY HELP!  HAPPY NEW YEAR!
>
> Robert Holder
> Denver, Colorado
>
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

 Hi Robert;

I'm looking for some interesting news and found yours.
You got a lot of nice tricks. But why hacking a long perl script with open's
and die's for a small task which
is quicker developed in a shell environment.
Here is my tip:

First decide what's the task:

     You want to display a  list of specific processes.
     What are the tools: (k|ba|c)sh, [e]grep, awk, sed, perl ...
     What is common to egrep, awk, perl ? Yes the regular expressions.
     Who is the winner perl (?) or [e]grep ? Not for all but perl is the
     best guess, egrep is easier to handle.
     The main advantage of perl is the rich flavour of its regular
     expressions.

I would recommend first try egrep its common on all platforms. If you familar
with perl than change the
egrep statements in  a perl statement.

But the task is small so you should not define large programs for a on line
snippet.

Tad McClellan has the answer as well. Think in regular expressions.

What is common and whats the difference.

     : '(dataserver).*(miler)+'
     : '(dataserver).*(citys)+'
     : '(dataserver).*(demo)+'

Could be written as : dataserver.*(miler|citys|demo)

No plus sign behind the brace is needed as Tad explained. As you see your
three lines are squeezed to on line.
So why you want to use a second file. You have no error checking and all the
information stuff. Insert this definition
in the script.

------------------->8-------------------------------------

     #!/bin/ksh
     # testing egrep and perl
     # maik hertha mhertha@ibm.net

     regex='dataserver.*(miler|citys|demo)|nedit'
     ps -eo pid,args | egrep $regex

-------------------8<-------------------------------------
You see this is smaller than your script and all the other perl scripts you
receive. You can shorten this if you insert
the regex-string directlly in the egrep command.

Now  we can try to use a perl snippet. (Yes I love perl and the regex
engine--sometimes I hate it :)

------------------->8-------------------------------------

     #!/bin/ksh
     # testing egrep and perl
     # maik hertha mhertha@ibm.net

     regex="dataserver.*(miler|citys|demo)|nedit"
     eval "ps -eo pid,args | perl -lne 'print if (m#$regex#);'"

-------------------8<-------------------------------------
The difference is the quoting for the regex string. In the first script we
should use single quotes to prevent
the shell for executing the shell-wildcard (*) in the second there is no need
for this. In the first shell we
can execute the ps command directly, in the second we have to eval(uate) the
command. Why?
The var $regex is set inside the script. When executing the command without
the eval, perl sees $regex as
a internal variable which is not defined (per default) and the regex is true
for all cases and perl prints out the
complete ps list. Our intention is: take $regex as an shell setting and
expand it before calling the perl-interpreter.
There for eval the command, which parses the command first, expand the var
$regex and runs the command. But
why quoting this command ? The perl expression is inside single quotes and so
the parser won't see the var $regex
as shell variable and won't replace its value.

I hope there is a little bit more light while using shells, regular
expressions and perl.

Thanks Maik d;-)


--
-------------------------------------------------------------
Maik Hertha                                 hartmann + hertha
private:mhertha@ibm.net      CATIA + UNIX System Spezialisten
office :maik.hertha@volkswagen.de                  WWW-Design



--------------A70B3AE2AE339F648A6DB844
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Rholder@sispost1.bis.adp.com wrote:
<BLOCKQUOTE TYPE=CITE>I want to store regular expressions in one file,
and then use a
<BR>shell script to read them into a shell variable within a "for" loop,
<BR>and then feed the expression into egrep via the shell variable.

<P>I'm doing this under Solaris 2.5.1.

<P>Here is my script:

<P>&nbsp; #!/usr/bin/ksh -x
<BR>&nbsp; #
<BR>&nbsp; # pidfinder -- find the PID of a process given a regex that
will
<BR>&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pluck that process from the output of ps -eo args,pid
<BR>&nbsp; #
<BR>&nbsp; for REGEX in `(cat /usr/local/scripts/pregex)`
<BR>&nbsp; do
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ps -eo pid,args | egrep
-v egrep | egrep $REGEX | awk '{print $1}'
<BR>&nbsp; done
<BR>&nbsp; # END OF SCRIPT

<P>....and here is what is in the file /usr/local/scripts/pregex:

<P>'(dataserver).*(miler)+'
<BR>'(dataserver).*(citys)+'
<BR>'(dataserver).*(demo)+'

<P>Here is what the lines I'm searching for look like:

<P>$ ps -eo pid,args | egrep dataserver
<BR>&nbsp; 970 /opt/sybase/bin/dataserver -d/db/mstr/miler_mstr.0 -smiler
<BR>18042 egrep dataserver
<BR>&nbsp; 959 /opt/sybase/bin/dataserver -d/db/mstr/demo_mstr.0 -sdemo
<BR>&nbsp; 948 /opt/sybase/bin/dataserver -d/db/mstr/citys_mstr.0 -scitys

<P>....I use the "ps -eo pid,args" rather than "ps -ef" or something more
<BR>usual so that I can see more of the sybase arguments.&nbsp; We have
three
<BR>dataservers running on this machine, and I need to be able to grab
the
<BR>line from "ps" for each one, as differentiated by the "miler", "citys"
<BR>and "demo" part of the expression.

<P>These regular expressions work when I type them in at the shell
<BR>prompt, like this:

<P>&nbsp; ps -eo pid,args | egrep '(dataserver).*(miler)+' | awk '{print
$1}'

<P>....this gives me the correct PID.&nbsp; But they don't work when plugged
in
<BR>via the $REGEX variable in the shell script...

<P>It seems to me that the meaning of the quotes is changing when they
are
<BR>in the content of the $REGEX shell variable, but I don't understand
how
<BR>and I'm starting to run out of ideas...

<P>I don't want to write a long, ugly script with lots of individual egrep
<BR>statements.&nbsp; Is there a way to do this, or should I try an entirely
<BR>different approach?&nbsp; I'm just starting to learn Perl, and I have
a
<BR>feeling this is easier to do in Perl, but I need to get this script
done,
<BR>like, yesterday...

<P>THANKS FOR ANY HELP!&nbsp; HAPPY NEW YEAR!

<P>Robert Holder
<BR>Denver, Colorado

<P>-------------------==== Posted via Deja News ====-----------------------
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://www.dejanews.com/">http://www.dejanews.com/</A>&nbsp;&nbsp;&nbsp;&nbsp;
Search, Read, Post to Usenet</BLOCKQUOTE>
&nbsp;Hi Robert;

<P>I'm looking for some interesting news and found yours.
<BR>You got a lot of nice tricks. But why hacking a long perl script with
open's and die's for a small task which
<BR>is quicker developed in a shell environment.
<BR>Here is my tip:

<P>First decide what's the task:
<BLOCKQUOTE>You want to display a&nbsp; list of specific processes.
<BR>What are the tools: (k|ba|c)sh, [e]grep, awk, sed, perl ...
<BR>What is common to egrep, awk, perl ? Yes the regular expressions.
<BR>Who is the winner perl (?) or [e]grep&nbsp;? Not for all but perl is
the best guess, egrep is easier to handle.
<BR>The main advantage of perl is the rich flavour of its regular expressions.</BLOCKQUOTE>
I would recommend first try egrep its common on all platforms. If you familar
with perl than change the
<BR>egrep statements in&nbsp; a perl statement.

<P>But the task is small so you should not define large programs for a
on line snippet.

<P>Tad McClellan has the answer as well.&nbsp;Think in regular expressions.

<P>What is common and whats the difference.
<BLOCKQUOTE>: '(dataserver).*(miler)+'
<BR>: '(dataserver).*(citys)+'
<BR>: '(dataserver).*(demo)+'</BLOCKQUOTE>
Could be written as : dataserver.*(miler|citys|demo)

<P>No plus sign behind the brace is needed as Tad explained. As you see
your three lines are squeezed to on line.
<BR>So why you want to use a second file. You have no error checking and
all the information stuff. Insert this definition
<BR>in the script.

<P>------------------->8-------------------------------------
<BLOCKQUOTE>#!/bin/ksh
<BR># testing egrep and perl
<BR># maik hertha mhertha@ibm.net

<P>regex='dataserver.*(miler|citys|demo)|nedit'
<BR>ps -eo pid,args | egrep $regex</BLOCKQUOTE>
-------------------8&lt;-------------------------------------
<BR>You see this is smaller than your script and all the other perl scripts
you receive. You can shorten this if you insert
<BR>the regex-string directlly in the egrep command.

<P>Now&nbsp; we can try to use a perl snippet. (Yes I love perl and the
regex engine--sometimes I hate it :)

<P>------------------->8-------------------------------------
<BLOCKQUOTE>#!/bin/ksh
<BR># testing egrep and perl
<BR># maik hertha mhertha@ibm.net

<P>regex="dataserver.*(miler|citys|demo)|nedit"
<BR>eval "ps -eo pid,args | perl -lne 'print if (m#$regex#);'"</BLOCKQUOTE>
-------------------8&lt;-------------------------------------
<BR>The difference is the quoting for the regex string. In the first script
we should use single quotes to prevent
<BR>the shell for executing the shell-wildcard (*) in the second there
is no need for this. In the first shell we
<BR>can execute the ps command directly, in the second we have to eval(uate)&nbsp;the
command. Why?
<BR>The var $regex is set inside the script. When executing the command
without the eval, perl sees $regex as
<BR>a internal variable which is not defined (per default) and the regex
is true for all cases and perl prints out the
<BR>complete ps list. Our intention is: take $regex as an shell setting
and expand it before calling the perl-interpreter.
<BR>There for eval the command, which parses the command first, expand
the var $regex and runs the command. But
<BR>why quoting this command ? The perl expression is inside single quotes
and so the parser won't see the var $regex
<BR>as shell variable and won't replace its value.

<P>I hope there is a little bit more light while using shells, regular
expressions and perl.

<P>Thanks Maik d;-)
<BR>&nbsp;
<PRE>--&nbsp;
-------------------------------------------------------------
Maik Hertha&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hartmann + hertha
private:mhertha@ibm.net&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CATIA + UNIX System Spezialisten
office :maik.hertha@volkswagen.de&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WWW-Design</PRE>
&nbsp;</HTML>

--------------A70B3AE2AE339F648A6DB844--



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

Date: 1 Jul 1998 20:06:29 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: What a Crappy World
Message-Id: <6ne4s5$e7c$1@news.NERO.NET>

In article <1dbgmda.17u89vs18g26emN@bay2-513.quincy.ziplink.net>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>Tomorrow, we'll learn about something called "a sense of humor".  :-)

Please do.


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

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


Administrivia:

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 3040
**************************************

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