[30834] in Perl-Users-Digest
Perl-Users Digest, Issue: 2079 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 26 03:09:49 2008
Date: Fri, 26 Dec 2008 00:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 26 Dec 2008 Volume: 11 Number: 2079
Today's topics:
Re: Buffering problem with 'open' - ideas ? <whynot@pozharski.name>
Re: Buffering problem with 'open' - ideas ? <asuter@cisco.com>
Re: Buffering problem with 'open' - ideas ? <asuter@cisco.com>
Re: FAQ 4.2 Why is int() broken? <whynot@pozharski.name>
new CPAN modules on Fri Dec 26 2008 (Randal Schwartz)
Re: Press a button <tim@burlyhost.com>
Re: Press a button <waveright@gmail.com>
Re: Understanding tempfile and open3 sln@netherlands.com
Re: Understanding tempfile and open3 <ced@blv-sam-01.ca.boeing.com>
Re: Understanding tempfile and open3 sln@netherlands.com
Re: Understanding tempfile and open3 sln@netherlands.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Dec 2008 04:32:58 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Buffering problem with 'open' - ideas ?
Message-Id: <slrngl8gja.2ih.whynot@orphan.zombinet>
On 2008-12-25, Asim Suter <asuter@cisco.com> wrote:
>
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:jpd7l4hkd8ugiucvoknl3750g1hhqn06rk@4ax.com...
>> "Asim Suter" <asuter@cisco.com> wrote:
>>>I need to run a command in interactive fashion as well as catch its
>>>output.
>>
>> Are you trying to reinvent the Expect module?
>>
>> jue
>
> Expect is useful when its needed to 'feed' input to program in an automated
> fashion.
> That's not my intent. I still need the operation be human controlled on the
> shell. The human
> may choose yes or no.
>
> Thanks but any other ideas ?
>
> Asim
Bravo! Nice shot! Is it a kind of template?
p.s. (on the subject) Consider *redirecting* output of your command
but simple capturing C<STDOUT>. L<open>, L<perlopentut>, L<IPC::Open2>
and others.
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Thu, 25 Dec 2008 23:04:13 -0800
From: "Asim Suter" <asuter@cisco.com>
Subject: Re: Buffering problem with 'open' - ideas ?
Message-Id: <1230275056.238010@sj-nntpcache-3.cisco.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:9j88l4tfp4uddiki4trm9qm4b0gmn42fq6@4ax.com...
> "Asim Suter" <asuter@cisco.com> wrote:
>>
>>"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
>>news:jpd7l4hkd8ugiucvoknl3750g1hhqn06rk@4ax.com...
>>> "Asim Suter" <asuter@cisco.com> wrote:
>>>>I need to run a command in interactive fashion as well as catch its
>>>>output.
>>>
>>> Are you trying to reinvent the Expect module?
>>
>>Expect is useful when its needed to 'feed' input to program in an
>>automated
>>fashion.
>>That's not my intent. I still need the operation be human controlled on
>>the
>>shell. The human
>>may choose yes or no.
>
> What's blocking the Perl program from asking the human and then using
> expect to feed the response to the other program?
>
> jue
If you have any solution to prevent the buffering ( the original problem ) -
post it -
But why push towards Expect When I do not want it ? Yes, I have used expect
before
And I know its good - but I feel its an overkill here.
It is not addressing my original question of buffering.
Asim
------------------------------
Date: Thu, 25 Dec 2008 23:13:40 -0800
From: "Asim Suter" <asuter@cisco.com>
Subject: Re: Buffering problem with 'open' - ideas ?
Message-Id: <1230275622.241603@sj-nntpcache-2.cisco.com>
"Eric Pozharski" <whynot@pozharski.name> wrote in message
news:slrngl8gja.2ih.whynot@orphan.zombinet...
> On 2008-12-25, Asim Suter <asuter@cisco.com> wrote:
>>
>> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
>> news:jpd7l4hkd8ugiucvoknl3750g1hhqn06rk@4ax.com...
>>> "Asim Suter" <asuter@cisco.com> wrote:
>>>>I need to run a command in interactive fashion as well as catch its
>>>>output.
>>>
>>> Are you trying to reinvent the Expect module?
>>>
>>> jue
>>
>> Expect is useful when its needed to 'feed' input to program in an
>> automated
>> fashion.
>> That's not my intent. I still need the operation be human controlled on
>> the
>> shell. The human
>> may choose yes or no.
>>
>> Thanks but any other ideas ?
>>
>> Asim
>
> >Bravo! Nice shot! Is it a kind of template?
Thats being courteous to fellow responders yet saving personal time.
You get the idea right ? :-)
>
> p.s. (on the subject) Consider *redirecting* output of your command
> but simple capturing C<STDOUT>. L<open>, L<perlopentut>, L<IPC::Open2>
> and others.
>
> --
> Torvalds' goal for Linux is very simple: World Domination
> Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Fri, 26 Dec 2008 04:22:16 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: FAQ 4.2 Why is int() broken?
Message-Id: <slrngl8fv8.2ih.whynot@orphan.zombinet>
On 2008-12-25, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> On 2008-12-23 20:03, PerlFAQ Server <brian@stonehenge.com> wrote:
>> --------------------------------------------------------------------
>>
>> 4.2: Why is int() broken?
>>
>> Your "int()" is most probably working just fine. It's the numbers that
>> aren't quite what you think.
>>
>> First, see the answer to "Why am I getting long decimals (eg,
>> 19.9499999999999) instead of the numbers I should be getting (eg,
>> 19.95)?".
>>
>> For example, this
>>
>> print int(0.6/0.2-2), "\n";
> print int(0.6/0.2), "\n";
>>
>> will in most computers print 0, not 1, because even such simple numbers
> will in most computers print 2, not 3, because even such simple numbers
>
> (The extra subtraction is not necessary to demonstrate the problem and is
> distracting)
>
Maybe it was derived from that
perl -wle '
printf qq|%e\n|, 0.6/0.2;
printf qq|%e\n|, 0.6/0.2-2;
printf qq|%e\n|, 0.6/0.2-3;
'
3.000000e+00
1.000000e+00
-4.440892e-16
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Fri, 26 Dec 2008 05:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Dec 26 2008
Message-Id: <KCGyIr.1pMp@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
AnyEvent-CouchDB-1.07
http://search.cpan.org/~beppu/AnyEvent-CouchDB-1.07/
a non-blocking CouchDB client based on jquery.couch.js
----
App-PPBuild-0.10
http://search.cpan.org/~exodist/App-PPBuild-0.10/
Perl Project Build System, The low-learning curve simple build system.
----
App-PPBuild-0.11
http://search.cpan.org/~exodist/App-PPBuild-0.11/
Perl Project Build System, The low-learning curve simple build system.
----
Business-PayPal-0.03
http://search.cpan.org/~phred/Business-PayPal-0.03/
Perl extension for automating PayPal transactions
----
Class-MOP-0.74
http://search.cpan.org/~drolsky/Class-MOP-0.74/
A Meta Object Protocol for Perl 5
----
Config-IniFiles-2.44
http://search.cpan.org/~shlomif/Config-IniFiles-2.44/
A module for reading .ini-style configuration files.
----
Convert-Color-IRC-0.03
http://search.cpan.org/~wolfman/Convert-Color-IRC-0.03/
Convert IRC colors to names or rgb hex codes.
----
Convert-IRC-Color-0.01
http://search.cpan.org/~wolfman/Convert-IRC-Color-0.01/
Convert IRC colors to names or hex codes.
----
DBD-DB2-1.3
http://search.cpan.org/~ibmtordb2/DBD-DB2-1.3/
DataBase Driver for DB2 UDB
----
DateTime-Set-0.26
http://search.cpan.org/~fglock/DateTime-Set-0.26/
Datetime sets and set math
----
Deliantra-Client-2.02
http://search.cpan.org/~mlehmann/Deliantra-Client-2.02/
----
File-Find-Object-0.1.4
http://search.cpan.org/~shlomif/File-Find-Object-0.1.4/
An object oriented File::Find replacement
----
KiokuDB-0.13
http://search.cpan.org/~nuffin/KiokuDB-0.13/
Object Graph storage engine
----
KiokuDB-Backend-CouchDB-0.01
http://search.cpan.org/~nuffin/KiokuDB-Backend-CouchDB-0.01/
CouchDB backend for KiokuDB
----
Lemonldap-NG-Common-0.9
http://search.cpan.org/~guimard/Lemonldap-NG-Common-0.9/
Common files for Lemonldap::NG infrastructure
----
Lemonldap-NG-Handler-0.9
http://search.cpan.org/~guimard/Lemonldap-NG-Handler-0.9/
The Apache protection module part of Lemonldap::NG Web-SSO system.
----
Lemonldap-NG-Manager-0.87
http://search.cpan.org/~guimard/Lemonldap-NG-Manager-0.87/
Perl extension for managing Lemonldap::NG Web-SSO system.
----
Lemonldap-NG-Portal-0.86
http://search.cpan.org/~guimard/Lemonldap-NG-Portal-0.86/
The authentication portal part of Lemonldap::NG Web-SSO system.
----
Log-Dispatchouli-1.000
http://search.cpan.org/~rjbs/Log-Dispatchouli-1.000/
a simple wrapper around Log::Dispatch
----
Module-Extract-VERSION-0.13
http://search.cpan.org/~bdfoy/Module-Extract-VERSION-0.13/
Extract a module version without running code
----
Parallel-Depend-3.02
http://search.cpan.org/~lembark/Parallel-Depend-3.02/
----
Parse-ErrorString-Perl-0.08
http://search.cpan.org/~pshangov/Parse-ErrorString-Perl-0.08/
Parse error messages from the perl interpreter
----
Simo-0.0201
http://search.cpan.org/~kimoto/Simo-0.0201/
Very simple framework for Object Oriented Perl.
----
Test-DistManifest-1.0
http://search.cpan.org/~frequency/Test-DistManifest-1.0/
Tests that your MANIFEST matches the distribution as it exists, excluding those in your MANIFEST.SKIP
----
WWW-Search-Yahoo-China-1.003
http://search.cpan.org/~mthurn/WWW-Search-Yahoo-China-1.003/
WWW::Search backend for searching Yahoo! China
----
WWW-Search-Yahoo-Japan-2.103
http://search.cpan.org/~mthurn/WWW-Search-Yahoo-Japan-2.103/
WWW::Search backend for searching Yahoo! Japan
----
Working-Daemon-0.29
http://search.cpan.org/~abergman/Working-Daemon-0.29/
Perl extension for blah blah blah
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Thu, 25 Dec 2008 22:08:54 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Press a button
Message-Id: <Wx_4l.10428$fs1.6429@newsfe05.iad>
pod wrote:
>
> Did you try this by
>> simply having the script post to the URL in question.
>
> ?? I dont know what you mean with that
Partly, the question was to see if this issue is related to your Perl
code (doesn't matter the language or method if that method or URL
doesn't work). The question was about using the same method (POST) to
send the arguments (URL with the fields and values) straight to the URL
from a mockup HTML page with that same URL, same arguments, etc. and
use a normal submit button (using a form tag in the HTML) and see if
that has the same result as trying to use the post method in the Perl
script. For that matter, if just the URL with the GET method works
with your browser that you have the script using. Just a suggestion to
ensure it works before you try and troubleshoot a script that's
resulting in a 403 error.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Thu, 25 Dec 2008 23:37:34 -0800 (PST)
From: Todd Wade <waveright@gmail.com>
Subject: Re: Press a button
Message-Id: <f7ba8b8a-3780-474a-b23f-7961fbedbfa6@i18g2000prf.googlegroups.com>
On Dec 25, 1:46 pm, pod <po...@gmx.net> wrote:
> Hello
>
> Thx for your answer - I use use the below code but I get a HTTP/1.0 403
> Forbidden. Any idea?
>
> ...
> $referer='http://10.0.0.138/cgi/b/is/_pppoa_/ov/?be=0&l0=1&l1=2&name=INTERNET';
>
> my $header = HTTP::Headers->new (
> 'ACCEPT'=>'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
> 'ACCEPT_LANGUAGE'=>'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3',
> 'REFERER'=>"$referer",
> 'USER_AGENT'=>'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)');
I was going to say that maybe the referer needed set, but it looks
like you're setting it here.
Do either 1 or 2 or both:
1. Open a raw socket to the web server in the router and send a copy
of the raw request and see if that works.
2. Look at the network traffic for the LWP request and modify the code
until it matches the sniffed successful request.
Todd W.
------------------------------
Date: Fri, 26 Dec 2008 04:16:52 GMT
From: sln@netherlands.com
Subject: Re: Understanding tempfile and open3
Message-Id: <bkm8l4t4lnq7flq0194ph0aflvjhi8p5rr@4ax.com>
On Thu, 25 Dec 2008 20:33:23 -0500, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "u" == usenet <usenet@schweikhardt.net> writes:
>
> u> On Dec 25, 3:34 am, Uri Guttman <u...@stemsystems.com> wrote:
> >> your problem is in that line. open3 doesn't connect a process to file
> >> handles that are open with files. it is meant to give you an open handle
> >> to talk to the subprocess. once open3 is called you have to do all the
> >> i/o afterwards - all it does is fork/exec the command while attaching
> >> the handles (which are not pre-opened to anything) to the stdio/err of
> >> the process.
>
> u> Thanks Uri, for pointing me to this. In fact, open3 has a way
> u> to use an existing file handle when it is prefixed with ">&".
> u> This works as expected:
>
>you are missing the core point. open3 doesn't do any I/O! a handle from
>a process can only be used in one direction at a time. so you can take
>an existing or new handle and connect it to a subprocess. that doesn't
>make a 'pipe' of i/o between the process and the file. it just reuses
>the existing handle and connects it to the process. you still need to
>read stderr from the process and write it to the file.
>
> u> Now the only ugly part here is that I seem unable to
> u> use $filehandle directly with open3 and ">&". Instead
> u> I go the detour via open FH, ">$filename". Hasn't
> u> tempfile() done something very similar (given me a
> u> handle and name)? Is there a way to make open3 accept
> u> some combination of ">&" and $filehandle without the
> u> FH detour? (I want tempfile for its race avoidance and
> u> autoremoval of temp file features).
>
>you can't do that. the handle from tempfile is for writing to it. the
>handle for stderr is for reading from the process. how could one handle
>be both?
>
>uri
huh? think again
sln
------------------------------
Date: Thu, 25 Dec 2008 20:41:52 -0800 (PST)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Understanding tempfile and open3
Message-Id: <4d0156d1-fada-4585-91e2-70928f83e6fa@r10g2000prf.googlegroups.com>
On Dec 25, 5:33 pm, Uri Guttman <u...@stemsystems.com> wrote:
> ...
> u> Now the only ugly part here is that I seem unable to
> u> use $filehandle directly with open3 and ">&". Instead
> u> I go the detour via open FH, ">$filename". Hasn't
> u> tempfile() done something very similar (given me a
> u> handle and name)? Is there a way to make open3 accept
> u> some combination of ">&" and $filehandle without the
> u> FH detour? (I want tempfile for its race avoidance and
> u> autoremoval of temp file features).
>
> you can't do that. the handle from tempfile is for writing to it. the
> handle for stderr is for reading from the process. how could one handle
> be both?
>
Not to jump in the middle but his example seems to
suggest he just wanted to use the existing filehandle
returned by File::Temp for Open3's child output rather
than having to open the output himself as he ended
up doing:
Jens> open FH, ">$filename" or die "$!";
Jens> my $pid = open3 (gensym, ">&FH", \*ERR, @cmd);
But Open3 docs suggest you should be able to use the
filehandle returned by File::Temp:
If CHLD_OUT or CHLD_ERR begins with ">&", then the
child will send output directly to that filehandle. In both
cases, there will be a dup(2) instead of a pipe(2) made.
So, if File::Temp returns the handle $filehandle, you should
be able to use ">&$filehandle" ... but no output appeared
in my test with ">&$filehandle" even with autoflush set; but, if the
file descriptor is used '>&=' . fileno($filehandle) , it does.
--
Charles DeRykus
------------------------------
Date: Fri, 26 Dec 2008 07:05:44 GMT
From: sln@netherlands.com
Subject: Re: Understanding tempfile and open3
Message-Id: <oe09l4djbo3deq4cmbq1u088q23c7k4c38@4ax.com>
On Thu, 25 Dec 2008 20:33:23 -0500, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "u" == usenet <usenet@schweikhardt.net> writes:
>
> u> On Dec 25, 3:34 am, Uri Guttman <u...@stemsystems.com> wrote:
> >> your problem is in that line. open3 doesn't connect a process to file
> >> handles that are open with files. it is meant to give you an open handle
> >> to talk to the subprocess. once open3 is called you have to do all the
> >> i/o afterwards - all it does is fork/exec the command while attaching
> >> the handles (which are not pre-opened to anything) to the stdio/err of
> >> the process.
>
> u> Thanks Uri, for pointing me to this. In fact, open3 has a way
> u> to use an existing file handle when it is prefixed with ">&".
> u> This works as expected:
>
>you are missing the core point. open3 doesn't do any I/O! a handle from
>a process can only be used in one direction at a time. so you can take
>an existing or new handle and connect it to a subprocess. that doesn't
>make a 'pipe' of i/o between the process and the file. it just reuses
>the existing handle and connects it to the process. you still need to
>read stderr from the process and write it to the file.
>
> u> Now the only ugly part here is that I seem unable to
> u> use $filehandle directly with open3 and ">&". Instead
> u> I go the detour via open FH, ">$filename". Hasn't
> u> tempfile() done something very similar (given me a
> u> handle and name)? Is there a way to make open3 accept
> u> some combination of ">&" and $filehandle without the
> u> FH detour? (I want tempfile for its race avoidance and
> u> autoremoval of temp file features).
>
>you can't do that. the handle from tempfile is for writing to it. the
>handle for stderr is for reading from the process. how could one handle
>be both?
>
>uri
The handle for tempfile (as he used it) and stderr globe ref are both
readers from the perspective of the caller, not writers.
sln
------------------------------
Date: Fri, 26 Dec 2008 07:08:23 GMT
From: sln@netherlands.com
Subject: Re: Understanding tempfile and open3
Message-Id: <pl09l41rpio96q66c744aonqrndot4al81@4ax.com>
On Fri, 26 Dec 2008 07:05:44 GMT, sln@netherlands.com wrote:
>On Thu, 25 Dec 2008 20:33:23 -0500, Uri Guttman <uri@stemsystems.com> wrote:
>
>>>>>>> "u" == usenet <usenet@schweikhardt.net> writes:
>>
>> u> On Dec 25, 3:34 am, Uri Guttman <u...@stemsystems.com> wrote:
>> >> your problem is in that line. open3 doesn't connect a process to file
>> >> handles that are open with files. it is meant to give you an open handle
>> >> to talk to the subprocess. once open3 is called you have to do all the
>> >> i/o afterwards - all it does is fork/exec the command while attaching
>> >> the handles (which are not pre-opened to anything) to the stdio/err of
>> >> the process.
>>
>> u> Thanks Uri, for pointing me to this. In fact, open3 has a way
>> u> to use an existing file handle when it is prefixed with ">&".
>> u> This works as expected:
>>
>>you are missing the core point. open3 doesn't do any I/O! a handle from
>>a process can only be used in one direction at a time. so you can take
>>an existing or new handle and connect it to a subprocess. that doesn't
>>make a 'pipe' of i/o between the process and the file. it just reuses
>>the existing handle and connects it to the process. you still need to
>>read stderr from the process and write it to the file.
>>
>> u> Now the only ugly part here is that I seem unable to
>> u> use $filehandle directly with open3 and ">&". Instead
>> u> I go the detour via open FH, ">$filename". Hasn't
>> u> tempfile() done something very similar (given me a
>> u> handle and name)? Is there a way to make open3 accept
>> u> some combination of ">&" and $filehandle without the
>> u> FH detour? (I want tempfile for its race avoidance and
>> u> autoremoval of temp file features).
>>
>>you can't do that. the handle from tempfile is for writing to it. the
>>handle for stderr is for reading from the process. how could one handle
>>be both?
>>
>>uri
>
>The handle for tempfile (as he used it) and stderr globe ref are both
>readers from the perspective of the caller, not writers.
>
>sln
And btw, both readers can be the same handle.
sln
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 2079
***************************************