[16174] in Perl-Users-Digest
Perl-Users Digest, Issue: 3586 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 18:11:16 2000
Date: Mon, 10 Jul 2000 15:11:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963267064-v9-i3586@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Jul 2000 Volume: 9 Number: 3586
Today's topics:
need post/lwp example <billw@dal.asp.ti.com>
Re: NT=>Unix text formatting <bwalton@rochester.rr.com>
OLE and excel <j.marshall@dial.pipex.com>
print command not found <sfox@earthlighttechnologies.com>
Re: Problem running CONFIGURE.COM from perl 5.6.0 <dan@tuatha.sidhe.org>
running system command as root from perl kmhanser@my-deja.com
Re: running system command as root from perl (brian d foy)
Servlet-like functionality in Perl? Session mgmt, Db Co <rgparker@west.net>
Re: Servlet-like functionality in Perl? Session mgmt, D <kperrier@blkbox.com>
split NONSENSE <kj0@mailcity.com>
Re: split NONSENSE (Randal L. Schwartz)
Re: String length? <uri@sysarch.com>
Re: String length? (Abigail)
Re: String length? (Malcolm Dew-Jones)
Re: String length? <aqumsieh@hyperchip.com>
User review scrip? <aa.ketola@kolumbus.fi>
win32 on unix <pkeating@americasm01.nt.com>
Re: win32 on unix <care227@attglobal.net>
Re: win32 on unix (Malcolm Dew-Jones)
Re: win32 on unix <carvdawg@patriot.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Jul 2000 16:16:32 -0500
From: Bill Webster <billw@dal.asp.ti.com>
Subject: need post/lwp example
Message-Id: <396A3D30.DEC49AD3@dal.asp.ti.com>
Hello folks,
My goal is to fill out a form for a given URL which uses the POST
method,
without the use of a browser. I understand using LWP is a good way to
go.
Looking through LWPCOOK, I found:
#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST =>
'http://www.perl.com/cgi-bin/BugGlimpse');
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');
my $res = $ua->request($req);
print $res->as_string;
...well http://www.perl.com/cgi-bin/BugGlimpse no longer exists, so
its hard for me to
play with this example. I would like an example program that will work,
so I can make
sure I'm starting at the right point to debug my program ( which I think
my problems my name/value pairs...).
Can someone send me an example similar to the one above that will
work?
Thanks loads,
Bill Webster ( billw@dal.asp.ti.com)
------------------------------
Date: Mon, 10 Jul 2000 19:53:18 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: NT=>Unix text formatting
Message-Id: <396A29F2.48AF60B7@rochester.rr.com>
DLachap419 wrote:
>
> My NT perl program outputs text which is then used on a Unix system. The
> problem is that the formatting is incorrect (and therefore unusable in my case)
> It seems the file saved out of my perl script on NT has the wrong EOL. I know
> there are differences between NT/unix in this regard but have not been able to
> come up with the correct one.
> I saved some properly formatted text on the unix system and made a dummy
> script on NT to just read in lines and save them out again without doing any
> processing. That text then formatted properly back on unix. But if I do a
> simple substitution on one line, no dice. I figure this has to be one of those
> idiot things so, ok, I'm an idiot, can anyone help?
How are you getting your text files back and forth between your NT
system and your Unix system? With most tools used for that purpose, the
proper conversion of text files is automatic if the tool is configured
properly. I would look at fixing your file access tool rather than
trying to cobble around with Perl to generate files in the foreign
format.
If you do want to do the cobble job, you will probably need to set
binmode on the filehandle, then change \n in your code to \f , and make
sure a binary file transfer is performed to Unix. You probably won't be
able to look at the resulting file on NT very well with most NT tools.
See, I told you you'd want to fix your file access tool.
--
Bob Walton
------------------------------
Date: Mon, 10 Jul 2000 21:39:54 +0000
From: Jon Marshall <j.marshall@dial.pipex.com>
Subject: OLE and excel
Message-Id: <396A42A9.B538CBEB@dial.pipex.com>
Having a slight problem with perl and OLE. After creating a spreadsheet
with columns and saving it, if you then re-open it how can you re-read a
columns worth of data without knowing how many cells you have filled in
that column ie. i have populated a column with 20 items - how can i
retrieve these items without knowing the range.
( i could keep a record in the top cell of each column with how many
items the column has in it but this seems very kludgy ).
I've figured out how to do most of the things i want from using the
Visual basic editor in excel but no matter what i try for this i can't
seem to work it out.
Any help would be much appreciated
Jon Marshall
------------------------------
Date: Mon, 10 Jul 2000 16:56:03 -0500
From: "Cheeby" <sfox@earthlighttechnologies.com>
Subject: print command not found
Message-Id: <8kdgmv$rhi$1@jair.pressenter.com>
I'm running through the O'Reilly book, Learning Perl and am stuck on the
Hello, World example...
(on SuSE 6.4)
#!/usr/bin/perl
print "What is your name?";
$name = <STDIN>;
chomp ($name);
print "Well, hello, $name!\n";
I've saved it as sample.pl, made it executable with chmod +x and when I run
it I get
./sample.pl: print: command not found
./sample.pl: line 6: syntax error near unexpected token ';'
./sample.pl: line 6: '$name = <STDIN>;'
I've got Perl 5, and it does reside in /usr/bin/perl
Any advice? Thanks,
Cheeby
------------------------------
Date: Mon, 10 Jul 2000 22:04:11 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Problem running CONFIGURE.COM from perl 5.6.0
Message-Id: <vLra5.13894$cu1.32081@news1.rdc1.ct.home.com>
Kid Prospect <kidprospect@softhome.net> wrote:
> When I run configure.com from anywhere including the command prompt of Win2k
> I get:
> Program too big to fit in memory
Don't *do* that! :) CONFIGURE.COM is the configuration command procedure
for VMS. (It's text--you can look at it if you want to see some scary DCL)
You need to do something else entirely to build on Windows.
Dan
------------------------------
Date: Mon, 10 Jul 2000 19:03:18 GMT
From: kmhanser@my-deja.com
Subject: running system command as root from perl
Message-Id: <8kd6l8$3ad$1@nnrp1.deja.com>
I need to be able to run a system command as root, from w/in a perl
script... that isn't running as root. Is that possible? Or, I need a
specific user (www) to be able to restart my apache server, as opposed
to root only being able to do this. Perhaps a re-install of apache...?
Here's what I need to do:
I have a perl CGI script that allows adding aliases to the end of the
httpd.conf file from a web page (page is only accessible internally).
However, after these aliases are added, the apache web server needs to
be restarted to activate the changes (or is there a way to make apache
re-read it's config file?). I'd like to put a button on the page that
restarts the server when pressed, so the changes can be activated from
the page as well.
What's the best way to do this?
Like I said, this is from a web page that is only accessible from our
internal network, so it's not quite as big of a security risk as it
might seem...
Thanx
Kevin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 10 Jul 2000 15:48:13 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: running system command as root from perl
Message-Id: <brian-ya02408000R1007001548130001@news.panix.com>
In article <8kd6l8$3ad$1@nnrp1.deja.com>, kmhanser@my-deja.com posted:
> I'd like to put a button on the page that
> restarts the server when pressed, so the changes can be activated from
> the page as well.
> What's the best way to do this?
the best way? don't use the web.
however...
i'd be tempted to have the CGI script create a file that signals
another process (cron job? daemon?) that the server needs to reload
the conf file (which is different than restarting the server)
> Like I said, this is from a web page that is only accessible from our
> internal network, so it's not quite as big of a security risk as it
> might seem...
it's worse, actually.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Mon, 10 Jul 2000 20:38:34 GMT
From: Randall Parker <rgparker@west.net>
Subject: Servlet-like functionality in Perl? Session mgmt, Db Conn Pooling?
Message-Id: <MPG.13d3d4f89705d8d6989821@news.onlynews.com>
In order to run Perl as a persistent process with Apache does it have to
be part of the Apache process as a plug-in?
Or can one set up Perl to run as a separate persistent process that
Apache passes selected URLs to via a socket connection?
Is there any kind of library available for Perl that will automate the
process of session management? In particular:
- automatically generate a session id when the requesting user doesn't
have one and the script asks for the user's session id
- Automatically go and set the session id on the user's browser if the
request for a session id requires that a session id be generated
- keep track of how long it has been since each session id saw traffic
and then delete a session id that is idle for more than a timeout period.
Basically, I'm looking for the sort of session management functionality
that Java Servlet containers provide.
Database connection pooling: Is there any way in a separate Perl process
to maintain a persistent database connection pool? I'd want that process
to, again, get URL requests from Apache via a socket connection.
Are there database connection pooling implementations available for
download?
------------------------------
Date: 10 Jul 2000 16:42:48 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Servlet-like functionality in Perl? Session mgmt, Db Conn Pooling?
Message-Id: <07179773D6DAB2C4.EB9CE83DB1F33EBF.E07D1D5072855EF8@lp.airnews.net>
Randall Parker <rgparker@west.net> writes:
> In order to run Perl as a persistent process with Apache does it have to
> be part of the Apache process as a plug-in?
>
> Or can one set up Perl to run as a separate persistent process that
> Apache passes selected URLs to via a socket connection?
You can have a 'lite' http process on the front end, with a mod_perl
enabled http process on the backend.
>
> Is there any kind of library available for Perl that will automate the
> process of session management? In particular:
> - automatically generate a session id when the requesting user doesn't
> have one and the script asks for the user's session id
> - Automatically go and set the session id on the user's browser if the
> request for a session id requires that a session id be generated
> - keep track of how long it has been since each session id saw traffic
> and then delete a session id that is idle for more than a timeout period.
>
> Basically, I'm looking for the sort of session management functionality
> that Java Servlet containers provide.
>
> Database connection pooling: Is there any way in a separate Perl process
> to maintain a persistent database connection pool? I'd want that process
> to, again, get URL requests from Apache via a socket connection.
>
> Are there database connection pooling implementations available for
> download?
Mod_perl can so this. Look at http://perl.apache.org
Specifically, look at http://perl.apache.org/guide/ for a lot of good
information on setting up mod_perl and apache.
Kent
--
Groovy! Smashing! Yay capitalism!
- Austin Powers, Man of Mystery
------------------------------
Date: 10 Jul 2000 15:56:01 -0400
From: kj0 <kj0@mailcity.com>
Subject: split NONSENSE
Message-Id: <8kd9oh$9ct$1@panix3.panix.com>
Consider the following Absurd Perl Behavior:
main::(-e:1): 1
DB<1> x (split /:/, ":a")
0 ''
1 'a'
(ok)
DB<2> x (split /:/, "a:")
0 'a'
(huh?)
DB<3> x (split /:/, ":")
empty array
(WHAT?!?)
How can I get the right behavior, i.e.
DB<?> x (split /:/, ":")
0 ''
1 ''
???
Thanks,
KJ
------------------------------
Date: 10 Jul 2000 13:00:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: split NONSENSE
Message-Id: <m1vgydzrga.fsf@halfdome.holdit.com>
>>>>> "kj0" == kj0 <kj0@mailcity.com> writes:
kj0> Consider the following Absurd Perl Behavior:
kj0> main::(-e:1): 1
kj0> DB<1> x (split /:/, ":a")
kj0> 0 ''
kj0> 1 'a'
kj0> (ok)
kj0> DB<2> x (split /:/, "a:")
kj0> 0 'a'
kj0> (huh?)
kj0> DB<3> x (split /:/, ":")
kj0> empty array
kj0> (WHAT?!?)
kj0> How can I get the right behavior, i.e.
kj0> DB<?> x (split /:/, ":")
kj0> 0 ''
kj0> 1 ''
By reading the manual. :)
perldoc perlfunc =>
split /PATTERN/,EXPR,LIMIT
split /PATTERN/,EXPR
split /PATTERN/
split Splits a string into an array of strings, and
returns it. By default, empty leading fields are
preserved, and empty trailing ones are deleted.
[...]
If LIMIT is specified and positive, splits into no
more than that many fields (though it may split
into fewer). If LIMIT is unspecified or zero,
trailing null fields are stripped (which potential
users of pop() would do well to remember). If
LIMIT is negative, it is treated as if an
arbitrarily large LIMIT had been specified.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 10 Jul 2000 19:05:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: String length?
Message-Id: <x7snthn6vf.fsf@home.sysarch.com>
>>>>> "MD" == Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> writes:
MD> sub get_length
MD> { my $str = shift;
MD> print '
MD> 123456789 123456789 123456789 123456789 123456789 123456789 123456789
MD> ';
MD> print "$str\n";
MD> print "Please enter the length of the string: ";
MD> $length = <STDIN>;
MD> return $length;
MD> }
BUG: you didn't chomp $length but that won't make a difference
unless it is used in a string context.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 10 Jul 2000 16:07:39 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: String length?
Message-Id: <slrn8mkc9r.7v7.abigail@alexandra.delanet.com>
Marcel Grunauer (marcel@codewerk.com) wrote on MMDIV September MCMXCIII
in <URL:news:slrn8mi1bh.51o.marcel@gandalf.local>:
$$ On Sun, 09 Jul 2000 21:45:34 GMT, Steve Palincsar <palincss@his.com> wrote:
$$ >
$$ ><jape>
$$ >Well, one could always create an array of characters by splitting on the
$$ >null string, then evaluating the array in a scalar context. There's
$$ >always more than one way to do it...
$$ ></jape>
$$
$$
$$ Sure there is another way to do it:
$$
$$ sub strlen {
$$ my $s = shift;
$$ my $l = 0;
$$ $l++ while substr($s,0,1,'');
$$ return $l;
$$ }
But that would be incorrect for any string containing a 0.
sub strlen {
local $_ = shift;
my $l = 0;
chop, $l ++ untill /^\z/;
$l;
}
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: 10 Jul 2000 13:11:07 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: String length?
Message-Id: <396a2ddb@news.victoria.tc.ca>
Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote:
: # get the length of a string, assuming its less than 70 characters long
: # and has no line feeds, CRs, etc, in it
: sub get_length
: { my $str = shift;
: print '
: 123456789 123456789 123456789 123456789 123456789 123456789 123456789
: ';
: print "$str\n";
: print "Please enter the length of the string: ";
: $length = <STDIN>;
chomp($length); # re: uri guttman (sp?)
: return $length;
: }
# requires a writable /tmp directory to work.
use POSIX;
sub get_length
{ my $str = shift;
my $length;
open TMP , ">/tmp/$$.get_length" or die "/tmp/$$.get_length: $!, ";
binmode TMP; # either necessary or makes no difference
print TMP , $str;
close TMP;
open TMP , "/tmp/$$.get_length" or die "/tmp/$$.get_length: $!, ";
binmode TMP; # either necessary or makes no difference
seek TMP , 0 , SEEK_END; # constant from POSIX, I hope
$length = tell TMP;
close TMP;
unlink "/tmp/$$.get_length" ; # if failure then continue anyway
return $length;
}
------------------------------
Date: Mon, 10 Jul 2000 21:02:34 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: String length?
Message-Id: <7a3dlhlmut.fsf@merlin.hyperchip.com>
"Simon H." <srh104@york.ac.uk> writes:
> Is there a quick way in Perl (like the predefined methods in, say, Java)
> to get the length of a string in terms of number of characters?
Everybody so far has given you some kind of answer (sarcastic or
not). Don't listen to them! String length is a function of Heisenberg's
principle:
sub heisenbergs_length {
my $s = shift;
my $length = 0;
$_ >= 0.5 && $length++ while $_ = rand > 0.1;
$length;
}
Note that the length changes as you are trying to measure it, just as
Heisenberg predicted.
:-)
--Ala
------------------------------
Date: Mon, 10 Jul 2000 22:38:03 +0300
From: "Arto Ketola" <aa.ketola@kolumbus.fi>
Subject: User review scrip?
Message-Id: <8kd84u$f12$1@news.kolumbus.fi>
Where I can get free user review scrip?
Thanks
Arto Ketola
------------------------------
Date: Mon, 10 Jul 2000 15:18:09 -0400
From: "Keating, Paul [SKY:C289:EXCH]" <pkeating@americasm01.nt.com>
Subject: win32 on unix
Message-Id: <396A2171.292E7618@americasm01.nt.com>
Hi.
I'm attempting to write some scripts to run on a unix box that will poll
a network to find the nodename, OS, and several other features of about
2000 windows NT and 95 boxes.
This is in an attempt to find new machines on the network in case I
wasn't notified of their deployment.
In other words, trying to keep them from falling throught the
cracks.......
I have two scripts, one finds all 95 machines in the domain, the other,
all the NT machines, but they run on an NT box, and have to be run from
an account with (at least) local admin access on every machine.
The scripts use the win32 module.....I was wondering if it's possible to
port these scripts to run using perl on Solaris so that I can administer
all of my backup tasks centrally.
So are the abilties of the module contained completely within the module
itself, or is it just a means to accessing tools within windows?
Any help would be appreciated.
Cheers,
Paul
------------------------------
Date: Mon, 10 Jul 2000 15:42:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: win32 on unix
Message-Id: <396A2725.91BFAD2E@attglobal.net>
"Keating, Paul [SKY:C289:EXCH]" wrote:
>
> Any help would be appreciated.
>
Best bet is to check first on CPAN (read the docs for the module
you are using as well) and then see if this question has come up
before. Search the archives of comp.lang.perl.modules.
If it isn't in the archives, a post to that group might be in order.
------------------------------
Date: 10 Jul 2000 12:59:02 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: win32 on unix
Message-Id: <396a2b06@news.victoria.tc.ca>
Keating, Paul [SKY:C289:EXCH] (pkeating@americasm01.nt.com) wrote:
: Hi.
: I'm attempting to write some scripts to run on a unix box that will poll
: a network to find the nodename, OS, and several other features of about
: 2000 windows NT and 95 boxes.
: This is in an attempt to find new machines on the network in case I
: wasn't notified of their deployment.
: In other words, trying to keep them from falling throught the
: cracks.......
: I have two scripts, one finds all 95 machines in the domain, the other,
: all the NT machines, but they run on an NT box, and have to be run from
: an account with (at least) local admin access on every machine.
: The scripts use the win32 module.....I was wondering if it's possible to
Well I don't know, but I would suspect not. The win32 module(s)
presumably use the routines provided by the wins32 OS (NT in your case).
However there is an application called 'samba' that runs on unix that
provides access to windows networking. That may provide some tools that
you could call from your perl script to get details about windows network
clients.
When all else fails, something like
$client_list = `some-samba-util -option all-visible-clients`;
# now compare current clients to previously saved list.
------------------------------
Date: Mon, 10 Jul 2000 17:37:09 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: win32 on unix
Message-Id: <396A4205.51B3ABD3@patriot.net>
> I have two scripts, one finds all 95 machines in the domain, the other,
> all the NT machines, but they run on an NT box, and have to be run from
> an account with (at least) local admin access on every machine.
This statement makes me wonder what modules you are using and how you are
writing your code. In the scripts I have written to do this, you don't need
to
have local admin access on all machines...
> The scripts use the win32 module.....I was wondering if it's possible to
> port these scripts to run using perl on Solaris so that I can administer
> all of my backup tasks centrally.
> So are the abilties of the module contained completely within the module
> itself, or is it just a means to accessing tools within windows?
The modules are simply wrappers around the Microsoft API...so you can't
just install the module on Solaris and expect it to run. However, you
should be
able to do some enumeration via smbclient or nmbclient calls.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3586
**************************************