[12345] in Perl-Users-Digest
Perl-Users Digest, Issue: 5945 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 10 11:07:21 1999
Date: Thu, 10 Jun 99 08:00:19 -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 Thu, 10 Jun 1999 Volume: 8 Number: 5945
Today's topics:
Re: block inside print ? <bill@fccj.org>
Definition of words in Perl and POSIX <6jmg@post.queensu.ca>
Difference of two variables ladlad@my-deja.com
Re: Difference of two variables (Tad McClellan)
Re: fork for DNS lookup - help <delete.the.nospam.kayec@gov.ns.ca>
Re: How do I write CGI in C++? (Marcel Grunauer)
How to sort an array of hashes by one of the hash field <william_holmes@nospamrocketmail.com.nospam>
Re: How to sort an array of hashes by one of the hash f <anfi@bigfoot.com>
Re: How to sort an array of hashes by one of the hash f (Larry Rosler)
HOWTO: Compiling Modules (columbus)
Intersection of SEVERAL ( eg. 5 -> ) lists (Thomas Weholt)
Re: Intersection of SEVERAL ( eg. 5 -> ) lists (Randal L. Schwartz)
Re: Intersection of SEVERAL ( eg. 5 -> ) lists <anfi@bigfoot.com>
Re: invoking a script (not in a subshell) <dshea@orion.pppl.gov>
Re: Looking for a Command Line E-Mailer for NT emarkert@my-deja.com
Re: Perl Program - Timeout (Randal L. Schwartz)
Re: Perldoc and Perlfaq <ludlow@us.ibm.com>
print command (<<) in perl CGI sunil@india-times.com
Re: print command (<<) in perl CGI <anfi@bigfoot.com>
Re: Regexpr for loop to handle e-address list (Tad McClellan)
Re: Removing the decimal? <joeyandsherry@mindspring.com>
Re: Script times-out after x minutes (Hasanuddin Tamir)
Re: SSH Authentication in Perl (Ton Hospel)
Re: Substitution with functions <Herve.Foucher___NO_SPAM@helio.org>
Re: Uploading image files.. paul.bunkham@synetica.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Jun 1999 09:46:08 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: block inside print ?
Message-Id: <375fc14e.0@usenet.fccj.cc.fl.us>
In article <375fa440.0@usenet.fccj.cc.fl.us>, "Bill Jones" <bill@fccj.org>
wrote:
<snip>
Reducing the problem to smallest test code:
$vFlag = "0|0|0|0|0|0|x|x|x";
print
" Well? ",
{
((split(/\|/, $vFlag))[7] eq 'x') ? 'do this' : 'do that'
},
"\n";
<snip>
>
> NOTE: The above does cause error -
> MoreInfoII.cgi: Odd number of elements in hash list at
> ./MoreInfoII.cgi line 57, <miData> chunk 826.
>
I forgot to mention that the HASH Reference ID is
printing and not what it is pointing to,
example output (under MacPerl) -
# Odd number of elements in hash list.
File 'MacOS:Desktop Folder:OddHashReference'; Line 3
Well? HASH(0x9fc5490)
OK, hmm, let's see... First we need to figure out
what kind of error it is:
Odd number of elements in hash list
(S) You specified an odd number of elements to a hash
list, which is odd, since hash lists come in key/value
pairs.
Then we should really search DejaNews for relevant discussions -
http://www.deja.com/[ST_rn=ps]/qs.xp?ST=PS&QRY=Odd+number+of+elements+in+has
h+assignment&defaultOp=AND&DBS=1&OP=dnquery.xp&LNG=english&subjects=&groups=
comp.lang.perl*&authors=&fromdate=&todate=&showsort=score&maxhits=100
Got 18 references (better than the 16000 from the
other search I had tried :)
Next,
After reading those 18 and about 100 of those others,
I decided I should try to de-reference the implied hash
using a \'string' slash. Nope. Then I fiddled with
'stringafication' of the reference. Stringification?
Who makes up these things? :)
Anyways,
After reading PerlFAQ4 - data Manipulation, at
http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_expand_function_
calls_i
I tried this:
$vFlag = "0|0|0|0|0|0|x|x|x";
print
" Well? ",
@{[
((split(/\|/, $vFlag))[7] eq 'x') ? 'is X' : 'is !X'
# If \'string' used, then generates: Well? SCALAR(0x9fc5178)
]},
"\n";
which prints: Well? is X
Which also reminds me that I've used this
'interpolation' trick in past scripts, twice
in fact; so now that I've spent yet another
hour looking up why I couldn't get the
SCALAR instead of the HASH - I should
remember better next time...
Lesson learned:
"Experience is a hard teacher, but you never forget!"
- WC Jones, 1982 (a Sneex quote from South Korea
during my year long stay at 25th Trans, 8th Army.)
I hope this will help others research their
problems better BEFORE posting to c.l.p.m :)
Thx,
-Sneex- :]
_________________________________________________________________________
$_ = "Jacksonville Perl Monger"; while(/([Jacksonville Perl Monger])/g){
print join(" ", map { defined $_ ? $_ : "" } $`, $&, $', $+), "\n"; }
------------------------------
Date: Thu, 10 Jun 1999 10:24:02 -0400
From: "Mark Goodaire" <6jmg@post.queensu.ca>
Subject: Definition of words in Perl and POSIX
Message-Id: <7johri$m7o$1@knot.queensu.ca>
The script that I'm writing requires me to match against patterns that are
ALMOST the same as the default word in PERL, \w, equivalent to the character
set [A-Za-z0-9_]. What I need is a slightly modified definition of \w, so
that \w will match characters in the set [A-Za-z0-9_-] for instance. Does
anyone know how I can do this? From the reading I've done I get the
impression that I need to use locales and possible some part of POSIX, but
the PERL documenation hasn't been much help.
Thanks,
MG
----------------------------------------------------------------------------
---------------------
J. Mark Goodaire *MAIL* ->
Packman Programmer 6jmg@post.queensu.ca
Information Technology Services *PHONE* ->
Stauffer Library, 011C 533-6000 ext. 77946
Queen's University *WEB* ->
Kingston, ON qlink.queensu.ca/~6jmg
----------------------------------------------------------------------------
----------------------
------------------------------
Date: Thu, 10 Jun 1999 12:03:16 GMT
From: ladlad@my-deja.com
Subject: Difference of two variables
Message-Id: <7jo9i0$g10$1@nnrp1.deja.com>
Hi,
I have a variable
$all="cherry, apple, plum, pear";
and this variable
$takeout="pear,cherry";
and I would like to get the difference of these two strings
that is
$remain="apple, plum";
What is the best way? Can you help please?
Thanks.
Ladislav Blazek
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 10 Jun 1999 04:34:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Difference of two variables
Message-Id: <tatnj7.ep4.ln@magna.metronet.com>
ladlad@my-deja.com wrote:
: I have a variable
: $all="cherry, apple, plum, pear";
: and this variable
: $takeout="pear,cherry";
: and I would like to get the difference of these two strings
: that is
: $remain="apple, plum";
: What is the best way? Can you help please?
------------------------
#!/usr/bin/perl -w
use strict;
my $all='cherry, apple, plum, pear';
my $takeout='pear,cherry';
$takeout =~ tr/,/|/; # convert to a regex
my $remain = join ', ', grep ! /\b$takeout\b/, split /, /, $all;
print "$remain\n";
------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Jun 1999 11:44:58 -0300
From: "kayec" <delete.the.nospam.kayec@gov.ns.ca>
Subject: Re: fork for DNS lookup - help
Message-Id: <_aQ73.1096$aP5.41876@sapphire.mtt.net>
Question for you.....
When your script does the lookups it sometimes returns 3-4....10 different
names for one IP. Now i realize this isn't a problem as it does actually
happen, but is their an easy way to modify the script to only give me one.
I don't care about the rest.
Otherwise i could write another script to go though and delete duplicates
but that would be slow and defeat the benefit of your fast (and very
through) DNS lookup.
thanks
kayec wrote in message ...
>WOW, thanks Michael....
>That is fast.
>
>Will have to lean FORK another day.
>: (
>
>Michael Fuhr wrote in message <7jkdmi$qej@flatland.dimensional.com>...
>>"kayec" <delete.the.nospam.kayec@gov.ns.ca> writes:
>>
>>> To speed up DNS lookups i've split my list of IPs into 5 different
files.
>>> Now i want to span five PERL programs to do the lookups.
>>> After the lookups are done i have to do more processing so i need to
know
>>> when the five processes are done.
>>>
>>> I think i want to use FORK for this but am not clear on the syntax....
>>
>>For an example of fast DNS lookups without forking, see the program
>>I posted a few months ago:
>>
>> http://www.deja.com/getdoc.xp?AN=455581292&fmt=text
>>
>>--
>>Michael Fuhr
>>http://www.fuhr.org/~mfuhr/
>
>
------------------------------
Date: Thu, 10 Jun 1999 12:54:16 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: How do I write CGI in C++?
Message-Id: <3763b538.15391912@enews.newsguy.com>
On Thu, 10 Jun 1999 14:02:41 +0300, Elia Weiss <elia@infogear.co.il>
wrote:
>
>Hi,
>I want to write a CGI in C++ (usually I use TCL/tk)
>but I don't know how to reach the environment variable
>(i.e. The data that being send by the user/browser
>and being set by the server as global/enviormment variable)
>
>So I do reach does var's?
>
>Is there any special Lib to work with CGI's?
>
>Is there any reason way not writing a CGI in c++ (i.e. versus. TCL)?
>
>Is there a better forum I should present this kind of questions?
>
And your Perl question is...?
Marcel
------------------------------
Date: Tue, 08 Jun 1999 18:31:58 -0700
From: william <william_holmes@nospamrocketmail.com.nospam>
Subject: How to sort an array of hashes by one of the hash fields????
Message-Id: <375DC40E.EADF321C@nospamrocketmail.com.nospam>
Hi,
I have made an array of hashes, and would like to arrange the order of
the array by an element in the hash. The code below is my attempt,
alas it doesn't work. Hoping somebody would point out my error or point
me in the direction of
some relevant information.
Thank you
William
#! /usr/bin/perl -w
@printers = qw( one0 two0 three0 four0 five0 six0 seven0 eight0 nine0
ten0 eleven0 twelve0 thirteen0 fourteen0 fifteen0 one1 two1 three1 four1
five1 six1 seven1 eight1 nine1 ten1 eleven1 twelve1 thirteen1 fourteen1
fifteen1 one2 two2 three2 four2 five2 six2 seven2 eight2 nine2 ten2
eleven2 twelve2 thirteen2 fourteen2 fifteen2 one3 two3 three3 four3
five3 six3 seven3 eight3 nine3 ten3 eleven3 twelve3 thirteen3 fourteen3
fifteen3);
$index=0;
$printercounter=0;
while($index < $#printers)
{
$printer[$printercounter++]={
one => "$printers[$index++]",
two => $printers[$index++],
three => $printers[$index++],
four => $printers[$index++],
five => $printers[$index++],
six => $printers[$index++],
seven => $printers[$index++],
eight => $printers[$index++],
nine => $printers[$index++],
ten => $printers[$index++],
eleven => $printers[$index++],
twelve => $printers[$index++],
thirteen => $printers[$index++],
fourteen => $printers[$index++]
} ;
$index++;
}
sub bystatus {
$printer[$a]{two} <=> $printer[$b]{two};
}
@onlinesort = sort bystatus @printer;
for $i ( 0 .. $#printer ){
print "$onlinesort[$i]{one}\n";
}
for $i ( 0 .. $#printer ){
for $role (keys %{ $onlinesort[$i]}){
print "element $i $role is $onlinesort[$i]{$role}\n";
}
}
------------------------------
Date: Thu, 10 Jun 1999 16:36:02 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: How to sort an array of hashes by one of the hash fields????
Message-Id: <375FCD52.4CA32CB8@bigfoot.com>
william wrote:
> I have made an array of hashes, and would like to arrange the order of
> the array by an element in the hash. The code below is my attempt,
> alas it doesn't work. Hoping somebody would point out my error or point
> me in the direction of
> some relevant information.
Use sort function:
my @out = sort { $a{sort_key} cmp $b{sort_key} } @in
--
Andrzej (Andrew) A. Filip
http://www.bigfoot.com/~anfi
E-mail: anfi@bigfoot.com
I NO LONGER USE anfi@polbox.com
Posting history (all addresses):
http://www.dejanews.com/profile.xp?author=Andrzej%20Filip&ST=PS
------------------------------
Date: Thu, 10 Jun 1999 06:45:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to sort an array of hashes by one of the hash fields????
Message-Id: <MPG.11c9614f345c8b61989baa@nntp.hpl.hp.com>
In article <375DC40E.EADF321C@nospamrocketmail.com.nospam> on Tue, 08
Jun 1999 18:31:58 -0700, william
<william_holmes@nospamrocketmail.com.nospam> says...
...
> sub bystatus {
> $printer[$a]{two} <=> $printer[$b]{two};
> }
>
> @onlinesort = sort bystatus @printer;
Three mistakes in the sortsub (not bad for so few keystrokes :-).
1. You are sorting on the indexes into the array of hashrefs, but the
function call passes the hashrefs themselves.
2. You are doing a numerical sort, but the values are strings.
3. Your formatting is rotten. :-)
sub bystatus {
$a->{two} cmp $b->{two};
}
@onlinesort = sort bystatus @printer;
or, for us space-savers:
@onlinesort = sort { $a->{two} cmp $b->{two} } @printer;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 10 Jun 1999 10:31:17 -0400
From: rfrink@pcso.com (columbus)
Subject: HOWTO: Compiling Modules
Message-Id: <uEDYn30s#GA.331@nih2naac.compuserve.com>
Hello,
I trying to compile some code that uses the SNMP 1.8 module. During the linking
phase, it complains about not finding the 'runops' symbol. My environment is:
HP-UX 10.20, HP ANSI C compiler, & Perl 5.00502.
Can anybody make a suggestion about how to get perl scripts that use modules
to compile ?
Thanks, in advance.
Rick
P.S. - Please CC my email on any responses
Rick Frink
PCSO Consulting
------------------------------
Date: Wed, 09 Jun 1999 20:26:23 GMT
From: u970130@studbo.hit.no (Thomas Weholt)
Subject: Intersection of SEVERAL ( eg. 5 -> ) lists
Message-Id: <375ecd74.1841552@news1.c2i.net>
Hi,
Perhaps I didn`t make it clear that I need to compute the intersection
of more than 4-5 lists, often 10-12. And this varies.
It is part of a "complex" search-engine.
Thanks for trying though.
------------------------------
Date: 10 Jun 1999 07:30:48 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Intersection of SEVERAL ( eg. 5 -> ) lists
Message-Id: <m1n1y82kmf.fsf@halfdome.holdit.com>
>>>>> "Thomas" == Thomas Weholt <u970130@studbo.hit.no> writes:
Thomas> Perhaps I didn`t make it clear that I need to compute the intersection
Thomas> of more than 4-5 lists, often 10-12. And this varies.
Perhaps you didn't make it clear why the solutions from the FAQ won't
work for you then.
Thomas> It is part of a "complex" search-engine.
At some point, you should punt and use a real database then.
Thomas> Thanks for trying though.
Well, it wouldn't be "trying" if we could get enough info to actually
help you. :)
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 10 Jun 1999 16:55:03 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: Intersection of SEVERAL ( eg. 5 -> ) lists
Message-Id: <375FD1C7.33DB3DAE@bigfoot.com>
Thomas Weholt wrote:
> Perhaps I didn`t make it clear that I need to compute the intersection
> of more than 4-5 lists, often 10-12. And this varies.
>
> It is part of a "complex" search-engine.
>
> Thanks for trying though.
Keep the list sorted - it makes the task very easy.
--
Andrzej (Andrew) A. Filip
http://www.bigfoot.com/~anfi
E-mail: anfi@bigfoot.com
I NO LONGER USE anfi@polbox.com
Posting history (all addresses):
http://www.dejanews.com/profile.xp?author=Andrzej%20Filip&ST=PS
------------------------------
Date: Thu, 10 Jun 1999 09:36:51 -0400
From: Dan Shea <dshea@orion.pppl.gov>
To: Thomas L|fgren <d95thl@ida.csd.uu.se>
Subject: Re: invoking a script (not in a subshell)
Message-Id: <Pine.SO4.4.05.9906100929480.27219-100000@orion.pppl.gov>
[Reply both emailed and posted]
Hi Thomas,
I was just offering an example $PATH there. I completely understand that
having '.' in your $PATH as the first entry is a "bad thing". Firstly, it
allows people to write malicious scripts/programs and name them after a
commonly used command (i.e. - 'ls') Of course, I was merely offering up
an example, and I do appreciate your concern, however, I am fully aware of
why that is bad. Because I am not a sysadmin, I am not authorized to
dictate who can put what in their $PATH.
I appreciate the concern however, and I thank you for your response to my
question.
Sincerely,
Dan Shea
My opinions are not those of my employer.
On 10 Jun 1999, Thomas L|fgren wrote:
>
> Why not make the perl script just print the results and do:
> PATH=`my_path_script $PATH`
>
> I do this, and it also means I can use the same script for other colon
> delimited lists (or lists with other delimiters if specified). My
> script also checks for '.' in the list, and removes it. Having the
> current directory in your PATH is a Bad Thing, and having it first in
> your PATH is just plain insanity. I'll provide an example if you
> can't figure out why.
>
> Tom
> --
> T. Lofgren - Wherever I lay my .emacs, that's my ${HOME}
> These opinions are mine, not yours. Get your own damn opinions.
>
>
------------------------------
Date: Thu, 10 Jun 1999 13:05:54 GMT
From: emarkert@my-deja.com
Subject: Re: Looking for a Command Line E-Mailer for NT
Message-Id: <7jod7b$hc9$1@nnrp1.deja.com>
Well since you are already using perl, why not use the module
Mail::Sendmail. It's OS independent - it will even work with NT.
In article <375D0F01.3E70D129@pyramid.de>,
Dominik Leinfelder <dominikl@pyramid.de> wrote:
> Jason Sova schrieb:
>
> > Does anybody here know where I could find a nice comand line based
> > E-Mailer that I could use with perl to send the results of a online
> > form? My OS is NT.
> >
> > Thanks
> > Jason
> > sova0001@algonquinc.on.ca
>
> Maybe blat.exe is helpful for you.
> just have a look @ http://gepasi.dbs.aber.ac.uk/softw/Blat.html
>
> greetinx
> Dominik Leinfelder
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 10 Jun 1999 06:01:30 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl Program - Timeout
Message-Id: <m1wvxc2or9.fsf@halfdome.holdit.com>
>>>>> "Prasad" == Prasad <prasad@panix.com> writes:
Prasad> I have a Perl program that is triggered from a form's button.
Prasad> That program sends e-mails to everyone listed in a file, which
Prasad> can contain more than 100 entries.
One of my WT columns addresses a similar concern, and you could use
the technique there to do the job. See Column # 20 at
<URL:http://www.stonehenge.com/merlyn/WebTechniques/>.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 10 Jun 1999 09:37:41 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Perldoc and Perlfaq
Message-Id: <375FCDB5.3045E40B@us.ibm.com>
R.Joseph wrote:
> I know this may sound stupid but I just got my hands on a copy of
> Slackware Linux, and I keep hearing much about "perldoc" and "perlfaq"
> and these things. Are these availible in Linux? If so, how would I go
> about using them? Any help is great, thanks.
perldoc perldoc
Actually, that's the whole answer right there. If you have perl
installed (correctly), you already have a program called perldoc.
Running 'perldoc perldoc' will give you instructions. You can also use
'man perldoc'.
Also, if you read 'man perl' you'll see right up near the top the list
of sections that the Perl manual has been split into (perl, perldelta,
perlfaq, etc...). You can use 'perldoc [section name]' to read that
section of the manual. For example, if you want to read about
subroutines, you'd read 'perldoc perlsub'.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Thu, 10 Jun 1999 12:52:32 GMT
From: sunil@india-times.com
Subject: print command (<<) in perl CGI
Message-Id: <7jocec$h1r$1@nnrp1.deja.com>
Hello there
I am writting a script in perl for one of my web application. when i
execute the script instead of showing the ouput on the screen
it generate/create a file and put the output in that file and offer it
as if unknown/new file type to save. Here is the piece of code Pls.
expedite the things.
$nn=<<"EOT"
<HTML>
<BODY>
<P>hello $$</P>
</P>
</BODY>
</HTML>
EOT
;
print "Content-type: text/html\n\n";
print $nn;
Thanks & Regards
Sunil Dua
sunil@india-times.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 10 Jun 1999 16:30:29 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: print command (<<) in perl CGI
Message-Id: <375FCC05.A28D919D@bigfoot.com>
sunil@india-times.com wrote:
> Hello there
>
> I am writting a script in perl for one of my web application. when i
> execute the script instead of showing the ouput on the screen
> it generate/create a file and put the output in that file and offer it
> as if unknown/new file type to save. Here is the piece of code Pls.
> expedite the things.
>
> $nn=<<"EOT"
> <HTML>
> <BODY>
> <P>hello $$</P>
> </P>
> </BODY>
> </HTML>
> EOT
> ;
>
> print "Content-type: text/html\n\n";
> print $nn;
>
> Thanks & Regards
> Sunil Dua
> sunil@india-times.com
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Put semicolon after "EOT"
---------------------------->
$nn=<<"EOT";
<HTML> <BODY>
<P>hello $$</P>
</BODY> </HTML>
EOT
<----------------------------
--
Andrzej (Andrew) A. Filip
http://www.bigfoot.com/~anfi
E-mail: anfi@bigfoot.com
I NO LONGER USE anfi@polbox.com
Posting history (all addresses):
http://www.dejanews.com/profile.xp?author=Andrzej%20Filip&ST=PS
------------------------------
Date: Thu, 10 Jun 1999 03:52:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regexpr for loop to handle e-address list
Message-Id: <1rqnj7.i64.ln@magna.metronet.com>
dalehend@flash.net wrote:
: I don't know, maybe senility has finally started to set in for me.
: Is the character following this sentence a backslash? \
Yes.
Backslashes are "consumed" by double quotes, and are not made
part of the resulting string.
: On Thu, 10 Jun 1999 01:18:18 -0500, rlb@intrinsix.ca (Lee) wrote:
: >
: > print "younme\@work.com shenhim\@work.com" . "\n";
But you already knew that, since you tried out the above,
so I dunno what your confusion is...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Jun 1999 08:38:59 -0400
From: <joeyandsherry@mindspring.com>
Subject: Re: Removing the decimal?
Message-Id: <7joc4i$jq2$1@nntp1.atl.mindspring.net>
EXCELLENT!
It worked perfectly, thanks alot!
Joey
Knowledge is power, I'm trying to get some...
------------------------------
Date: 11 Jun 1999 03:45:37 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Script times-out after x minutes
Message-Id: <slrn7lv5i9.6ud.hasant@borg.intern.trabas.co.id>
On 09 Jun 1999 21:55:32 GMT,
mikane@shell3.ba.best.com <mikane@shell3.ba.best.com> wrote:
>
> I have a Perl script (client) that executes a program on another UNIX box
> (server) using RPC. The server has timeouts which sometimes fail stalling
> the client. How can I code the client such that it terminates execution
> after 5 min while it is waiting for a responce fron the server.
Use alarm()/eval()/die() combination.
perldoc -f alarm
perldoc -f eval
perldoc -f die
HTH,
-hasan-
uhm, no more sig(h)
------------------------------
Date: 10 Jun 1999 13:46:06 GMT
From: ton@att-unisource.net (Ton Hospel)
To: kirbyk@best.com (K. Krueger)
Subject: Re: SSH Authentication in Perl
Message-Id: <7jofiu$cja$1@hunin.hoofddorp.aucs>
[Posted and mailed]
In article <7bn77g$hgv$1@shell2.ba.best.com>,
kirbyk@best.com (K. Krueger) writes:
> I have some perl scripts that need to use ssh and scp to securely do stuff
> (in this case, modify mailserver configurations to block spammers.) This
> works great if someone manually logs on and does the ssh authentication
> (ie, ssh-add) before running the scripts.
>
> This is good, but it would be great if I could automate the processing into
> a cronjob. The trick is, how do I achieve an ssh-authenticated environment
> in cron? The reason this seems hard, to me, is that I can't seem to redirect
> input to the ssh-add program without it popping up the X-Gui instead.
>
> A short sample script (Not written for style points):
>
> #!/usr/local/bin/perl
>
> $password = "MyPassword\n";
> open SSH, "|ssh-add" || die "Cannot open: $!";
> print SSH $password;
> close SSH;
> print "After ssh-add\n";
> print `ssh-add -l`;
> print `ssh othermachine cat samplefile`;
>
> With correct password and machinenames filled in, this pops up the magic
> ssh-add gui without adding the key. Since my goal is to do this
> non-interactively in cron, this is bad.
>
> Is this a solved problem? How do I move my ssh-dependant scripts into
> cron? Can I use Perl to help me with this. It _does_ work if I make a
> blank ssh passphrase, but we really don't want to have a blank passphrase
> that gives us root access to the mailservers.
>
> I realize that the solution to this may not really be a Perl question -
> but I'm hoping that it is, and someone can point me to something I can
> wrap the ssh-add stuff in. (Is there a Perl way to do expect-like shell
> control?)
>
> Thanks for any help. Emailed copies of posts appreciated. (I _do_ read
> this group, but email will reach me faster, and I'm impatient.)
>
I do this kind of stuff all the time. Just don't try to do normal
password authentication, but use RSA authentication.
i.e. on the machine from which you want to connect, use ssh-keygen to
make a key for the job you want to do. On the target machine, add
the public part of this key in your authorized_keys file (possibly with
a "forced command" if you want it more secure). On the connecting side,
make sure you connect using the generated key (you can set defaults in
the .config file).
In this setup you want in fact to AVOID using the ssh-agent, so in your
perl code you should do something like (notice the AUTH_SOCK line):
sub ssh {
my ($pid, $fh);
local(*IN, *IN0, *OUT, *OUT0);
pipe(*IN0, *IN) || die "Could not create input pipe: $!";
pipe(*OUT, *OUT0) || die "Could not create output pipe: $!";
defined($pid = fork()) || die "Could not fork: $!";
if ($pid) { # parent
close(*IN0);
close(*OUT0);
$fh = select(IN);
$| = 1;
select($fh);
return (*OUT, *IN);
} else { # child
close(*IN);
close(*OUT);
unless (open(STDOUT, ">&OUT0")) {
print STDERR "Could not dup OUT0 to STDOUT\n";
exit 1;
}
unless (open(STDIN, "<&IN0")) {
print STDERR "Could not dup IN0 to STDIN\n";
exit 1;
}
close(*IN0);
close(*OUT0);
# Turns of use of authentication agent
delete $ENV{"SSH_AUTH_SOCK"};
exec($::ssh, @_);
# Just some general paranoia
print STDERR "Exec failed: $!";
exit 1;
}
}
------------------------------
Date: Thu, 10 Jun 1999 12:43:44 GMT
From: Herve Foucher <Herve.Foucher___NO_SPAM@helio.org>
Subject: Re: Substitution with functions
Message-Id: <7jobtt$gr0$1@nnrp1.deja.com>
> Firstly, you don't need to escape `#'
OK. Sorry. There are so many strange caracters in Perl...
> and you need the /e switch to evaluate the subroutine
> (and other statements that need to be evaluated).
>
> $a_string =~ s/##(\w+)#/&MyPerlFunction($1)/ge;
It works! But I prefer using $&
Why do you use $1 ?
> > << Hello I am yppah to receive some swen >>
>
> Eh? You just want to reverse those words?
No. Of course NOT. Just an example! ;-)
Thank you and many thanks to others who also answered.
----------------------------------------------------------------------
Herve FOUCHER, HELIO
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 10 Jun 1999 12:38:47 GMT
From: paul.bunkham@synetica.com
Subject: Re: Uploading image files..
Message-Id: <7jobkm$gnr$1@nnrp1.deja.com>
> I have been workinga similar stuff, and found some great examples at
> http://www.idocs.com
> The only things I'm still struggling a little with is how to get at
the
> information available from the uploadInfo("$filename")
>
> Dan
>
I am having the same problems, my form encoding is right, and the file
seems to turn up (I can get at the filename), but calling uploadInfo
just returns some kind of null value and the file handle is missing. I
think it is something to do with the reported bugs of using file ypload
handles in a package that the CGI object wasn't created in, but the
given fix doesn't work. Has abyone got any other ideas?
Thanks,
Paul.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
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 5945
**************************************