[7705] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1331 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 17 14:38:48 1997

Date: Mon, 17 Nov 97 11:02:13 -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           Mon, 17 Nov 1997     Volume: 8 Number: 1331

Today's topics:
     Re: regexp cruncher in perl. Please help. <rootbeer@teleport.com>
     SQL Perl question <aegis@outland.cyberwar.com>
     Re: SQL Perl question <rsmith@nac.net>
     Re: SQL Perl question <mark_aurit@mail.northgrum.com>
     stripping Unix carraige returns <mark_aurit@mail.northgrum.com>
     Re: stripping Unix carraige returns (Jeremy D. Zawodny)
     Re: stripping Unix carraige returns (Tad McClellan)
     Re: Taint checking problem - insecure PATH <rootbeer@teleport.com>
     Re: What is going on here? <rootbeer@teleport.com>
     Re: Writing a daemon process <rootbeer@teleport.com>
     Re: Writing a daemon process <jay@rgrs.com>
     Re: Writing a daemon process <barnett@houston.Geco-Prakla.slb.com>
     Re: Year2000 problem with localtime(); <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 17 Nov 1997 10:35:23 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ravi Kumar <ravi@centtech.com>
Subject: Re: regexp cruncher in perl. Please help.
Message-Id: <Pine.GSO.3.96.971117103007.12318U-100000@usertest.teleport.com>

On Fri, 14 Nov 1997, Ravi Kumar wrote:

> 	I have a bunch of multi-thousand line files containing lines
> which should be eliminated from a bunch of million line files. Obviously
> cannot use anything but perl

Obviously. :-)

As I understand your problem, one file has a list of thousands of key
numbers (among other stuff). You need to edit the other file to remove any
entry which contains a key number which was listed in the first file. Is
that right?

If the key numbers are (relatively-small) integers, you could use a
bitstring to remember which ones to throw out, by using vec(). That should
be efficient and quick. Does that work for you? 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 17 Nov 1997 15:56:28 GMT
From: Aegis <aegis@outland.cyberwar.com>
Subject: SQL Perl question
Message-Id: <64ppfc$blv$1@bandit.cyberwar.com>

I really need to know if this is possible. I am looking to 
 write a perl script on unix to access an SQL database on windows
 NT. Is this possible? I know there are Perl SQL routines but can 
 they access an NT Sql server? Or is it possible in C on unix? 

 Any help would be appreciated, I would like to know before I 
 go digging through CPAN. 

thanks, 
Aegis



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

Date: Mon, 17 Nov 1997 11:29:38 -0500
From: Rick Smith <rsmith@nac.net>
Subject: Re: SQL Perl question
Message-Id: <347070F2.5C7E7688@nac.net>

netsearch for 'sqsh'

stands for structured query shell

sybase has linux client libraries for free that will allow
you to access microsoft sql servers.

we do it here to dynamically build password files,
radius authentication databases, accoutning, etcetc.

Aegis wrote:

> I really need to know if this is possible. I am looking to
>  write a perl script on unix to access an SQL database on windows
>  NT. Is this possible? I know there are Perl SQL routines but can
>  they access an NT Sql server? Or is it possible in C on unix?
>
>  Any help would be appreciated, I would like to know before I
>  go digging through CPAN.
>
> thanks,
> Aegis



--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Don't go with a spineless ISP;                   Rick Smith
        we have more backbone."                   rsmith@nac.net

(201) 983-0725     net @ccess corporation     (201) 983-0453 Fax
                     http://www.nac.net

Quake!                  games@nac.net                      MUDs!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




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

Date: Mon, 17 Nov 1997 16:33:00 GMT
From: "Mark Aurit" <mark_aurit@mail.northgrum.com>
Subject: Re: SQL Perl question
Message-Id: <01bcf376$8754bfa0$3d846380@NGW20072982.dssd.northgrum.com>

Do you also have a database on UNIX? If so, you can often directly access
the NT dbms from the
UNIX one, at which point Perl has nothing to do with it.

Aegis <aegis@outland.cyberwar.com> wrote in article
<64ppfc$blv$1@bandit.cyberwar.com>...
> I really need to know if this is possible. I am looking to 
>  write a perl script on unix to access an SQL database on windows
>  NT. Is this possible? I know there are Perl SQL routines but can 
>  they access an NT Sql server? Or is it possible in C on unix? 
> 
>  Any help would be appreciated, I would like to know before I 
>  go digging through CPAN. 
> 
> thanks, 
> Aegis
> 
> 


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

Date: Mon, 17 Nov 1997 16:34:54 GMT
From: "Mark Aurit" <mark_aurit@mail.northgrum.com>
Subject: stripping Unix carraige returns
Message-Id: <01bcf376$cb4ad1e0$3d846380@NGW20072982.dssd.northgrum.com>

I have a web page that uses Perl to write the output of a form to a
comma-seperated file, which I download into Excel 
(the file is created on a SGI Box running IRIX (Unix)).
The problem is when people use carriage returns in
Textarea boxes; Excel doesnt like them!
So obviously, I need to do a simple pattern match and
replace; just convert any carraige returns to spaces.
The manual I have isnt clear on what character represents
a carriage return (again, this is on Unix). Can someone help
me with this?

Thanks, Mark
auritma@NOSPAM.mail.northgrum.com


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

Date: Mon, 17 Nov 1997 17:15:55 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: stripping Unix carraige returns
Message-Id: <34717b85.325778314@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Mon, 17 Nov 1997 16:34:54 GMT, "Mark Aurit"
<mark_aurit@mail.northgrum.com> wrote:

>The manual I have isnt clear on what character represents
>a carriage return (again, this is on Unix). Can someone help
>me with this?

Perhaps you need a more clear manual.

In any case, it's likely that you need to hunt for occurances of \n,
\r, or the two together.

Shouldn't be hard to figure out in your case. You have the data. Just
throw a simple test script together.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Mon, 17 Nov 1997 12:08:16 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: stripping Unix carraige returns
Message-Id: <g61q46.ku8.ln@localhost>

Mark Aurit (mark_aurit@mail.northgrum.com) wrote:
: I have a web page that uses Perl to write the output of a form to a
: comma-seperated file, which I download into Excel 
: (the file is created on a SGI Box running IRIX (Unix)).
: The problem is when people use carriage returns in
: Textarea boxes; Excel doesnt like them!
: So obviously, I need to do a simple pattern match and
: replace; just convert any carraige returns to spaces.
: The manual I have isnt clear on what character represents
  ^^^^^^^^^^^^^^^^^

Uhh. What manual is that?

What about the manual that is shipped with the perl distribution itself?

That is the most authoritative manual that exists for perl...


: a carriage return (again, this is on Unix). Can someone help
: me with this?


grep 'carriage return' *.pod


finds 9 matches, which leads to this part of the 'perlre' man page:

--------------------------
Characters may be specified using a metacharacter syntax much like that
used in C: "\n" matches a newline, "\t" a tab, "\r" a carriage return,
"\f" a form feed, etc.  More generally, \I<nnn>, where I<nnn> is a string
of octal digits, matches the character whose ASCII value is I<nnn>.
Similarly, \xI<nn>, where I<nn> are hexadecimal digits, matches the
character whose ASCII value is I<nn>. The expression \cI<x> matches the
ASCII character control-I<x>.  Finally, the "." metacharacter matches any
character except "\n" (unless you use C</s>).
--------------------------


Use the docs, Luke.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Mon, 17 Nov 1997 10:13:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ernest Mueller <ernestm@towery.com>
Subject: Re: Taint checking problem - insecure PATH
Message-Id: <Pine.GSO.3.96.971117095630.12318Q-100000@usertest.teleport.com>

On Fri, 14 Nov 1997, Ernest Mueller wrote:

> OK, we have a CGI Perl script with tainting enabled, which when run from
> the command line works fine.  When run from the Web server it gives us
> the "insecure $env{path} while running with -t switch at..." error. 
> However, it appears that the PATH is set just fine. 

It's not the contents; it's the taintedness. If you like the contents just
as they are, simply hard-code that as a literal string.

   $ENV{PATH} = '/usr/sbin:/usr/bsd:/sbin';

(Of course, it's important that every dir and subdir in the PATH be
secure, too.) 

> I'd rather not define spurious PATHs in every CGI I write. 

Why not? :-)  That's what I do. But if you don't want to do that, one idea
would be to make code which will properly sanitize the PATH at runtime. 
But you should do this with caution: How can you tell at runtime whether a
particular PATH entry is safe? It's not an unsolvable problem, just a
crucial one. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Mon, 17 Nov 1997 10:55:23 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: gnewton@cch.com.au
Subject: Re: What is going on here?
Message-Id: <Pine.GSO.3.96.971117105254.12318X-100000@usertest.teleport.com>

On Thu, 13 Nov 1997 gnewton@cch.com.au wrote:

> open car, "$dog";
> if ($!) {

Although that may work sometimes, it's not the recommended way to test for
a successful open. In fact, I think it's responsible for the error you're
seeing. This is better. 

    unless (open CAR, $dog) {
	# perhaps print something using $!
	...

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Mon, 17 Nov 1997 09:52:17 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Writing a daemon process
Message-Id: <Pine.GSO.3.96.971117094611.12318N-100000@usertest.teleport.com>

On Fri, 14 Nov 1997, Dave Barnett wrote:

> I'm attempting to write a script that checks disk space on several of
> our servers, and creates a report from the information.  I've been
> requested to try to make the process a daemon process so that it is not
> dependent on 'cron' kicking off the job. 

That's easy to do. Just write it as if cron would start it, then use cron
as the daemon. :-)  (I'm joking, but is there some real reason why cron
can't be used? If you're on a properly-running modern Unix-type system,
cron should be reliable.) 

> 3.  Should this daemon process be something short that calls the
>     'workhorse' script at set intervals (once every 5 minutes, once
>     every 4 minutes...), or should the daemon be the 'workhorse' script
>     itself.

That first one is my recommendation, of course. Cron already takes care of
the problem of concurrency, so that's even better. (That is, what if you
run it every five minutes, but it takes ten minutes to finish?)

But if you really need it to be a daemon, just wrap the core of it in a
loop like this:

    while (1) {		# Infinite loop
	# do whatever...
	sleep 5*60;
    }

 ...and start it with an ampersand on the command line. But have I
mentioned that using cron is a better way to do it? :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 17 Nov 1997 13:07:22 -0500
From: Jay Rogers <jay@rgrs.com>
To: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Writing a daemon process
Message-Id: <82lnynjsx0.fsf@shell2.shore.net>

Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:
> I'm attempting to write a script that checks disk space on several of
> our servers, and creates a report from the information.  I've been
> requested to try to make the process a daemon process so that it is not
> dependent on 'cron' kicking off the job.
> 
> My questions are:
> 1.  Is there some reading material on the subject?  perlfaq8 had some
>     information on forking a daemon (I guess he's done  :-)  ), but I
>     haven't found anything about actually writing one.  I'm fairly new
>     to unix programming and Perl.

Get the book "Advanced programming in the Unix Environment" by
W. Richard Stevens.

> 2.  What is the 'most efficient' manner to use when creating a daemon
>     process?

There aren't really any efficiency considerations to *creating* a
daemon.

> 3.  Should this daemon process be something short that calls the
>     'workhorse' script at set intervals (once every 5 minutes, once
>     every 4 minutes...), or should the daemon be the 'workhorse' script
>     itself.

Don't break up the program for performance reasons.  If you need to
modularize code for use in other programs then create your own
library.

You can use sleep() to wake up at various intervals.

> 4.  While on the documentation subject:  what is the Panther book? 
>     Heard it existed (vaguely), but never spotted.

http://www.ora.com/catalog/advperl/noframes.html

--
Jay Rogers
jay@rgrs.com


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

Date: Mon, 17 Nov 1997 12:19:15 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Writing a daemon process
Message-Id: <34708AA3.7DF8@houston.Geco-Prakla.slb.com>

Tom Phoenix wrote:
> > I've been
> > requested to try to make the process a daemon process so that it is not
> > dependent on 'cron' kicking off the job.
> 
> That's easy to do. Just write it as if cron would start it, then use cron
> as the daemon. :-)  (I'm joking, but is there some real reason why cron
> can't be used? If you're on a properly-running modern Unix-type system,
> cron should be reliable.)

Well, cron is pretty reliable, AFAIK, but ... he is the more
knowledgeable of the two of us, in that respect.

His comment was that the system sometimes gets overloaded, and so cron
cannot run the requested job at the specified time.  *shrug*

> 
> > 3.  Should this daemon process be something short that calls the
> > 'workhorse' script?
> That first one is my recommendation, of course. Cron already takes care of
> the problem of concurrency, so that's even better. (That is, what if you
> run it every five minutes, but it takes ten minutes to finish?)

(The script is pretty short -- somewhere between 2 & 13 seconds,
depending on load & system)

> 
> But if you really need it to be a daemon, just wrap the core of it in a
> loop like this:
> 
>     while (1) {         # Infinite loop
>         # do whatever...
>         sleep 5*60;
>     }
> 
> ...and start it with an ampersand on the command line. But have I
> mentioned that using cron is a better way to do it? :-)

Tom,

Thanks for the insight.  I hadn't thought of that.

The system administrator's supervisor is the one who asked about it. 
I'm just the poor slob who has to program in Perl ( ;-) ).

The objective is to get the demand on system resources (i.e. system
calls such as df (this script does several to determine file system
names)-- we have MANY NFS mounted file systems, so sometimes df will
hang for a short period) to a minimum.

He suggested setting it up as a daemon process, so I was looking into
the possibility.  I'm not convinced that the daemonic route is the way
to go, but I'm writing this to his specs, so ... as long as the
sysadmin's are happy, I'll go on creating strange incantations.  :-)

Is there an equivalent to the df command within Perl?  I haven't seen
one, yet, but that doesn't mean it isn't available.  My theory (somewhat
substantiated) is that shell commands either as system calls or backtick
calls are slower than the equivalent Perl code.  I could be wrong,
but....

Dave

-- 
"Security through obscurity is no security at all."
                -comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Mon, 17 Nov 1997 09:54:51 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Mr. Yen-Ming Chen" <chenym@dufu.math.ncu.edu.tw>
Subject: Re: Year2000 problem with localtime();
Message-Id: <Pine.GSO.3.96.971117095407.12318P-100000@usertest.teleport.com>

On 14 Nov 1997, Mr. Yen-Ming Chen wrote:

>  In a DEC Alpha, the localtime can present up to year 2038, Jan. 19th,
> 11:14:07. So that means it(Unix) will have a "year 2038" problem?? :)

Many of us are planning to retire from the world of programming at the end
of 2037. :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

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

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