[18644] in Perl-Users-Digest
Perl-Users Digest, Issue: 812 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 1 11:10:33 2001
Date: Tue, 1 May 2001 08:10:14 -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: <988729813-v10-i812@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 1 May 2001 Volume: 10 Number: 812
Today's topics:
Multiple errors running newspro.cgi <r.borkent@123chello.nl>
Re: one-line stderr, stdout redirection (Villy Kruse)
Passing open file handles (sockets included) to child <mxvera@qwest.com>
Perl manual in info format? <paul.groves@oucs.ox.ac.uk>
Re: Perl manual in info format? <paul.groves@oucs.ox.ac.uk>
Q: Using 'rename' with CGI <news@shannonbrown.net>
Re: Remove Adult Files with Perl (Tad McClellan)
Re: requiring something I only need once (Greg Bacon)
Re: Run script as a daemon ? bo.forslund@abc.se
Re: Should Perl be first? <newspost@coppit.org>
Re: Should Perl be first? (Rudolf Polzer)
Re: Strange string -> num conversion (Richard J. Rauenzahn)
Re: Strange string -> num conversion <ren@tivoli.com>
Re: Strange string -> num conversion (Rudolf Polzer)
Re: System Call within Daemon - TAKE 2 <mxvera@qwest.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 01 May 2001 14:33:15 GMT
From: RonB <r.borkent@123chello.nl>
Subject: Multiple errors running newspro.cgi
Message-Id: <3AEEC8F8.60205@123chello.nl>
I get these errors when I try to run this perl script. It's a wll known
news management program that I use on Hypermart. I cant get it to work
on my own server (apache) this is the output I get when I run it from
console:
linux:/usr/local/httpd/cgi-bin/newspro # perl -w newspro.cgi
Name "main::nplang_DateFormat" used only once: possible typo at
newspro.cgi line 1501.
Name "main::SilentBuild" used only once: possible typo at newspro.cgi
line 969. Name "main::newsdate" used only once: possible typo at
newspro.cgi line 1118.
Name "main::ArcHtmlExt" used only once: possible typo at newspro.cgi
line 800.
Name "main::ChangedItems" used only once: possible typo at newspro.cgi
line 1227.
Name "main::EnableDailyArchiving" used only once: possible typo at
newspro.cgi line 1575.
Name "main::newtime" used only once: possible typo at newspro.cgi line 817.
Name "main::glossaryon" used only once: possible typo at newspro.cgi
line 744.
Name "main::JustLoadSubs" used only once: possible typo at newspro.cgi
line 113.Name "main::nplang_12Hour" used only once: possible typo at
newspro.cgi line 1498.
Name "main::FormFieldsModifySize" used only once: possible typo at
newspro.cgi line 1133.
Name "main::currenttime" used only once: possible typo at newspro.cgi
line 816. Name "main::npconfigversion" used only once: possible typo at
newspro.cgi line 232.
Name "main::nplibBuild" used only once: possible typo at newspro.cgi
line 235.
Name "main::NewsID" used only once: possible typo at newspro.cgi line 761.
Name "main::nplangversion" used only once: possible typo at newspro.cgi
line 238.
Use of uninitialized value in pattern match (m//) at newspro.cgi line 249.
Use of uninitialized value in concatenation (.) at nplib.pl line 161.
Use of uninitialized value in numeric ne (!=) at nplib.pl line 161.
Use of uninitialized value in concatenation (.) at nplib.pl line 161.
Use of uninitialized value in concatenation (.) at nplib.pl line 161.
Use of uninitialized value in read at nplib.pl line 181.
Use of uninitialized value in string eq at newspro.cgi line 268.
Use of uninitialized value in string eq at newspro.cgi line 278.
Use of uninitialized value in string eq at newspro.cgi line 283.
Use of uninitialized value in string eq at newspro.cgi line 312.
Use of uninitialized value in string eq at newspro.cgi line 1276.
Use of uninitialized value in crypt at newspro.cgi line 1298.
Use of uninitialized value in crypt at newspro.cgi line 1298.
Use of uninitialized value in string ne at newspro.cgi line 1298.
Use of uninitialized value in length at newspro.cgi line 1298.
Use of uninitialized value in pattern match (m//) at newspro.cgi line 1299.
Content-type: text/html
<html>
<head>
<title>NewsPro: NewsPro Login (Authorized Users Only)</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
p { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
.navbar { font-family: Arial, Helvetica, sans-serif; font-size: 9pt}
.navlink { font-family: Arial, Helvetica, sans-serif; font-size: 9pt;
color: #ffffff}
td { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
A:hover { color: #ffffff; text-decoration: none}
.nptitle { }
.npcontent { }
.npfooter { }
-->
</style>
</head><body bgcolor="#FFCC66" text="#CCCCCC" link="#FFCC33"
vlink="#FFCC33" alink="#FFCC33">
<div align="center">
<table width="60%" border="1" bordercolor="#666666"
cellpadding="4" cellspacing="0" align="center" class="nptitle">
<tr bgcolor="#000099">
<td>
<div align="center"><b><font face="Verdana, Arial,
Helvetica, sans-serif" color="#FFCC33">NewsPro Setup: NewsPro Login
(Authorized Users Only)</font></b></div>
</td>
</tr>
</table>
<br>
<table width="90%" border="1" bordercolor="#666666"
cellpadding="8" cellspacing="0" align="center" class="npcontent">
<tr bgcolor="#990000">
<td>
<form action="http://:?login" method="post">
<p> Username: <input type="text" name="uname"><br>
Password: <input type="password" name="pword"></p>
<input type="submit" name=submit value="Log In"></form>
<br><br>To set up NewsPro, enter setup as your username
and leave the password blank.
</td></tr></table></body></html>
linux:/usr/local/httpd/cgi-bin/newspro #
Can anybody tell me what is going on here?
Ron
------------------------------
Date: 1 May 2001 14:20:29 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: one-line stderr, stdout redirection
Message-Id: <slrn9ethhd.45b.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 1 May 2001 13:49:10 +0200, Rudolf Polzer <eins@durchnull.de> wrote:
>
>Can you still use IO::Select when you have >30 open sockets? select() does
>not work because the bit vector can only hold fileno()s in 0..31.
>
That would depend on the unix version, many of those can go considerably
higher than 31 in the select bitmap.
Villy
------------------------------
Date: Tue, 01 May 2001 08:52:48 -0500
From: Michael Vera <mxvera@qwest.com>
Subject: Passing open file handles (sockets included) to child
Message-Id: <3AEEBFB0.C34B0075@qwest.com>
--------------2BE664B1E5C320F85BCE486F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Ok, so I find in the camel book, edition III, on page 423:
"To avoid granting implicit access to all possible filehandles, Perl
automatically closes any filehandles it has opened (including pipes and
sockets) whenever you explicitly exec a new program or implicitly
execute one through a call to a piped open, system, or qx// (backticks).
"
### Open our socket...
#
$sock = new IO::Socket::INET (LocalHost => $host,
LocalPort => $port,
Proto => 'tcp',
Listen => 5,
Reuse => 1,
);
die "Could not connect: $!" unless $sock;
while ($new_sock = $sock->accept()) {
...
print $new_sock "Starting dm_oracle\n";
open(SYS, "$bin_path/start_dm_oracle |" );
SYS->autoflush(1);
while(<SYS>) {
chomp($_);
print $new_sock "$_<br>\n";
}
sleep 5;
print $new_sock " done.<br>\n";
close(SYS);
So at this point, isn't $new_sock simply a filehandle? And wouldn't it
NOT be passed to the child as per page 423?
Thanks,
Mike
--------------2BE664B1E5C320F85BCE486F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Ok, so I find in the camel book, edition III, on page 423:
<p>"To avoid granting implicit access to all possible filehandles, Perl
automatically closes any filehandles it has opened (including pipes and
sockets) whenever you explicitly <b>exec</b> a new program or implicitly
execute one through a call to a piped <b>open</b>, <b>system</b>, or <b>qx//
</b>(backticks). "
<br>
<br> <font face="Courier New,Courier">###
Open our socket...</font>
<br><font face="Courier New,Courier"> #</font>
<br><font face="Courier New,Courier"> $sock = new IO::Socket::INET
(LocalHost => $host,</font>
<br><font face="Courier New,Courier">
LocalPort => $port,</font>
<br><font face="Courier New,Courier">
Proto => 'tcp',</font>
<br><font face="Courier New,Courier">
Listen => 5,</font>
<br><font face="Courier New,Courier">
Reuse => 1,</font>
<br><font face="Courier New,Courier">
);</font>
<br><font face="Courier New,Courier"> die "Could not connect: $!"
unless $sock;</font>
<br><font face="Courier New,Courier"> while ($new_sock = $sock->accept())
{</font><font face="Courier New,Courier"></font>
<p><font face="Courier New,Courier">...</font><font face="Courier New,Courier"></font>
<p><font face="Courier New,Courier"> print $new_sock "Starting
dm_oracle\n";</font>
<br><font face="Courier New,Courier"> open(SYS, "$bin_path/start_dm_oracle
|" );</font>
<br><font face="Courier New,Courier"> SYS->autoflush(1);</font>
<br><font face="Courier New,Courier"> while(<SYS>)
{</font>
<br><font face="Courier New,Courier"> chomp($_);</font>
<br><font face="Courier New,Courier"> print
$new_sock "$_<br>\n";</font>
<br><font face="Courier New,Courier"> }</font>
<br><font face="Courier New,Courier"> sleep 5;</font>
<br><font face="Courier New,Courier"> print $new_sock
" done.<br>\n";</font>
<br><font face="Courier New,Courier"> close(SYS);</font><font face="Courier New,Courier"></font>
<p>So at this point, isn't $new_sock simply a filehandle? And wouldn't
it NOT be passed to the child as per page 423?
<p>Thanks,
<br>Mike</html>
--------------2BE664B1E5C320F85BCE486F--
------------------------------
Date: Tue, 1 May 2001 15:42:52 +0100
From: "Paul Groves" <paul.groves@oucs.ox.ac.uk>
Subject: Perl manual in info format?
Message-Id: <9cmi0a$3cj$1@news.ox.ac.uk>
Does anyone know where I can obtain the Perl manual (for 5.005) in "info"
format? I'd like to be able to use this with emacs and cperl mode and the
FAQ etc.
thanks
Paul
------------------------------
Date: Tue, 1 May 2001 15:49:40 +0100
From: "Paul Groves" <paul.groves@oucs.ox.ac.uk>
Subject: Re: Perl manual in info format?
Message-Id: <9cmid2$3k1$1@news.ox.ac.uk>
"Paul Groves" <paul.groves@oucs.ox.ac.uk> wrote in message
news:9cmi0a$3cj$1@news.ox.ac.uk...
> Does anyone know where I can obtain the Perl manual (for 5.005) in "info"
> format? I'd like to be able to use this with emacs and cperl mode and the
> FAQ etc.
Don't worry, I've found it at:
http://www.cpan.org/doc/manual/info/perl5/
------------------------------
Date: Tue, 01 May 2001 13:28:06 GMT
From: "Shannon Brown" <news@shannonbrown.net>
Subject: Q: Using 'rename' with CGI
Message-Id: <GRyH6.384$tD6.31021@nnrp1.ptd.net>
Persistent but odd issue ....
Perl 5.003
Linux 2.2
Apache 1.3
I have a log file that records banner click-throughs on a private
dog-related web site. The log file is executed using CGI. The logging
capability has been functioning for close to two years and seems to work
fine.
A log report analysis tool is available on the server to create short
reports on banner activity -- usually once per month. The report seems to
be creating problems because the log file is randomly deleted after running
the report.
Here is the structure of the system:
-- banner logging CGI scipt is running
-- report (separate script) runs and does
-- renames the production log file to a temporary file
(banner logging script regenerates a new log file if needed)
-- opens the temporary log file
-- locks temporary log file
-- reads temporary log file
-- unlocks temporary log file
-- renames the tempoary log file to the production file
(data is lost while the report runs and this is OK)
In most cases, this is OK. I assume that if the script dies, the final
rename would not occur and a backup would exist. Losing the small amount of
data while the report runs is negligable. However, in some cases, the
entire production file is lost. That is, both the temporary and production
files are lost.
This has caused quite an issue because the entire data file was lost. Why
does this happen when using rename? Is this an OS, Perl, or implementation,
issue? I understand that file locks are only 'suggestions' to the OS, but
rename should work since it works directly with the OS. That is, I see
these as two different issues.
I included the relevant code below. The '#NEW' statements were added after
the problem started occurring.
NOTES:
The systems is hosted in a shared web hosting environment and disk space is
limited (which is why a simple copy was not used originally).
if (-e $bannerclickthroughrecord)
{
my $tempfile = $bannerdbpath . "cttemp.txt" ;
my $backup = $tempfile . ".backup" ; # NEW
copy($bannerclickthroughrecord,$backup) ; #NEW
rename $bannerclickthroughrecord, $tempfile ;
open (IN, $tempfile) || die "Cannot open file $!" ;
flock(IN, $file_lock) ;
#Read db one line at a time
while(<IN>)
{
#Keep a running count of all lines
$ctc = $ctc + 1 ;
#Parse each record
($realdate, $realtime, $siteid, $bannerid, $ip,
$referer, $browser) = split(/\^\^/, $_) ;
#Create a unique key for the hash
my $ctpair = "$siteid-$bannerid" ;
#Check the dates for validity
#If the key already exists then augment the counter
(hash value) by 1.
#If the key does not exist, create a new key.
if ( ($realdate > $begindate) && ($realdate <
$enddate) )
{
#Actual valid count
$vctc = $vctc + 1 ;
if ( exists ($bannerctcounts{$ctpair}) &&
$ctpair ne "" )
{
$bannerctcounts{$ctpair} =
$bannerctcounts{$ctpair} + 1 ;
}
else
{
$bannerctcounts{$ctpair} = 1 ;
}
}
}
flock(IN, $file_unlock) ;
close(IN) ;
rename $tempfile, $bannerclickthroughrecord ;
------------------------------
Date: Tue, 1 May 2001 07:04:25 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Remove Adult Files with Perl
Message-Id: <slrn9et61p.iom.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>Sorry, Tad... I usually DO look first.
OK, sorry.
>I just can't find things at
>Googley-goo as well as I could at deja.
You and everyone else who is breathing :-(
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 01 May 2001 13:56:17 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: requiring something I only need once
Message-Id: <tetg41aj1p9q32@corp.supernews.com>
In article <4apretguh01qj0q0qfqcj3jk09sfr1814a@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
: Peter Seebach wrote:
:
: >Trivial test program:
: > foo.pl:
: > my @foo = (1);
: > 1;
: >
: > bar.pl:
: > #!/usr/bin/perl -w
: > require "foo.pl";
: > foreach $i (@foo) {
: > print "$i\n";
: > }
: >
: >Running "bar.pl" gets me:
: >Name "main::foo" used only once: possible typo at ./bar.pl line 3.
:
: If you want the same @foo, and it looks like you do, then DON'T make it
: a lexical! You NEED a global variable there!
Not true:
% cat Foo.pm
package Foo;
my @foo = (1);
{ no strict;
my $pkg = caller;
*{$pkg . '::foo'} = \@foo;
}
1;
% cat bar.pl
#!/usr/bin/perl -w
use Foo; # use, not require
foreach $i (@foo) {
print "$i\n";
}
% ./bar.pl
1
In the root article, Peter talked about his program behaving as expected,
but I imagine that he expected the contents of @foo to be printed (which
doesn't happen).
The reason for switching to use is that the name needs to be seen at
compile time to squelch the warning.
Greg
--
Cop: I can put you in Queens on the night of the hijacking.
Hockney: Really? I live in Queens. Did you put that together yourself?
------------------------------
Date: Tue, 01 May 2001 16:55:38 +0200
From: bo.forslund@abc.se
Subject: Re: Run script as a daemon ?
Message-Id: <3AEECE6A.FF19A500@abc.se>
Hello!
I need a dummy-daemon that just loads itself as a daemon doing nothing so
I can test init.d scripts. And I don't know much of perl programming.
Some distros have a function called checkproc, If a daemon is running and
the command "checkproc some-daemon" checkproc answers with a pid number. I
think it is same with Debians start-stop-daemon.
Do You know if it is some kind of standard when writing Linux daemons,
I mean... The command "checkproc some-daemon" shall some-daemon be written
in some way that it tells its pid if it is running?
I have a small perl script simmilar to yours below, but if I run checkproc
on it I get no pid. It would be nice to know how to get the script report
its pid when called by checkproc or start-stop-daemon.
I'm not really a perl programmer and here is the script, I call it dummyd.
Thanks in advande
Bo Forslund
#!/usr/bin/perl -w
use POSIX qw(setsid);
chdir '/' or die "Can't chdir to /: $!";
umask 0;
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
while(1) {
sleep(5);
print "Meep-Meep\n";
}
Bryan Coon wrote:
> Do you mean as a unix command? If so, 'program.pl &' will do it. But
> if you are looking for perl stuff (since you are posting to a perl group
> I hope this is the case) you can use system(), exec(), or if you want to
> get really fancy you can use some posix stuff to spin off a process that
> will not cause your original thread to wait for completion:
>
> sub forkJob {
> my $pid = fork;
> die "Can't fork: $!" unless defined $pid;
> if ($pid == 0) {
> if (POSIX::setsid == -1) {
> die "can't setsid: $!";
> }
> open STDOUT, ">/dev/null";
> open STDIN, ">/dev/null";
> exec "somereallycoolprogram.pl";
> die "Can't exec $!";
> }
> }
>
------------------------------
Date: Tue, 1 May 2001 09:19:27 -0400
From: David Coppit <newspost@coppit.org>
To: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Should Perl be first?
Message-Id: <Pine.SUN.4.33.0105010912140.7659-100000@mamba.cs.Virginia.EDU>
[posted & mailed]
On Tue, 1 May 2001, Martien Verbruggen wrote:
> On Sun, 29 Apr 2001 13:35:06 -0400, David Coppit
> <newspost@coppit.org> wrote:
>
> > My impression of VB is that it's a much simpler language than Perl
> > or certainly C++, but probably not as simple as C. There are still
> > a lot of annoying aspects, such as scoping issues and
> > declarations. Perl's syntax will cause you more grief, but you'll
> > probably find the language much more powerful than VB.
>
> Hmmm. I would certainly not call C simple. Most certainly not. The
> syntax isn't hard, writing simple stuff in it isn't hard, but
> writing a large production ready library or program in C is
> certainly hard, and requires loads of programming discipline.
C is simple. Programming in C is not. :) Heck, programming in Perl
isn't simple either unless you use some discipline. It's just that in
Perl you have to use a little discipline in variable declarations and
usage, while in C you have to use a lot of discipline in memory
management.
> Besides that, C lives so dangerously close to the machine that it's
> very easy to create code that inexplicably fails to produce correct
> results when you compile it on a different platform.
Agreed.
> Oh, and don't forget to pick up some general language-independent
> algorithm stuff. Knuth's got some good stuff on that [2].
> [2] Donald Knuth, The art of computer programming.
I don't recommend this text for beginners, except to browse it in the
bookstore and get the gestalt that writing correct code is very hard.
Knuth gets into a lot of rigor that is likely to swamp a beginner. A
beginning data structures and algorithm book should do the trick,
although keep in mind that Perl's built-in data structures are so
powerful you may never need the DS stuff. :)
--
David
------------------------------
Date: Tue, 1 May 2001 18:56:45 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Should Perl be first?
Message-Id: <slrn9etqmd.d8k.eins@www42.t-offline.de>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> If you want to become a professional programmer, a good one, learn some
> other languages, and C should probably be in there [1].
Really? Is C still widely used? AFAIK C++ is, but C? OK, programming
handhelds and things like that has to be done in C, but since space is
normally not an issue, C++ is much more used because it is more powerful.
I even noticed it is hard to learn C when you know C++!
--
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"
------------------------------
Date: 30 Apr 2001 18:33:11 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Strange string -> num conversion
Message-Id: <988655591.4804@hpvablab.cup.hp.com>
"Shay Harding" <sharding@ccbill.com> writes:
>Curious if this isn't more OS dependant? I tried it with the following
>configs:
>
>RedHat 7 w/ Perl 5.6.0 === 2.125
>Mandrake 7.2 w/ Perl 5.6.0 === 2.125
>FreeBSD 3.5 w/ Perl 5.005_03 === 1
>FreeBSD 4.2 w/ Perl 5.6.0 === 1
Another datapoint:
HPUX 11.00 w/ Perl 5.6.0 === 1
$ perl -le 'print "0x1.2" + 1'
1
$ perl -le 'print "0x12" + 1'
1
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: 01 May 2001 09:26:36 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Strange string -> num conversion
Message-Id: <m31yq9no0z.fsf@dhcp9-172.support.tivoli.com>
On Tue, 1 May 2001, eins@durchnull.de wrote:
> Ren Maddox <ren@tivoli.com> wrote:
>> On Mon, 30 Apr 2001, eins@durchnull.de wrote:
>>
>> Still, the only way I can get the original "2.125" output is by
>> including a decimal place:
>>
>> perl -le 'print 1 + "0x1.2"'
>
> Did you try the C program?
I did, with results matching Perl as expected.
Though I'm not sure why you ask....
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 1 May 2001 19:06:26 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Strange string -> num conversion
Message-Id: <slrn9etr8i.d8k.eins@www42.t-offline.de>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> According to Jean-Louis Leroy <jll63@easynet.be>:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> >
> > > Something is fishy. What Perl version are you using? On what
> > > system?
> >
> > I found out on a Red Hat 6.2 system that had perl 5.005. I don't have
> > access to it right now. The examples I posted were made on my home
> > computer (see below).
> >
> > Now if I try this on perl 5.6.0 on NT 4 in a vmware computer, I get
> > the expected result (i.e. 1).
> >
> > And when I try again on my computer at work (SUSe 7) I get 19 (looks
> > like 0x12 is interpreted as a hex number; makes sense).
>
> In that case the quotes around "0x12" probably got eaten by a shell.
> The string "0x12" is 0 in numeric context. The fractional number you
> apparently got remains mysterious.
>
> > So the problem would be...glibc??
>
> Unlikely. That would have to be a pretty massive bug.
Did anyone try my C program? Does it always give the same output as perl?
Then we _have_ found a glibc bug (or a locale bug; the manpage says that
it depends on the locale; perldoc locale shows, however, that the default
locale is the "POSIX" locale).
I post it here again:
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv)
{
printf ("%f\n", atof ("0x12"));
printf ("%f\n", atof ("0x1.2"));
}
which should normally print
0
0
but prints on my computer
18.000000
1.125000
Could you please try it? If it always displays the same result as
perl, there is really a glibc bug (or misfeature).
--
#!/usr/bin/perl -- Random sig generator. Editor command in slrn => ~/siggs
$F=shift;open H,"+<$F";$_=join"",<H>;$s=index$_,"\n\n-- \n";$s<0||truncate
H,$s;close H;system"$ENV{EDITOR} $F</dev/tty>/dev/tty";$s=$n=0;for#sichtig
(<~/siggs/*>){++$n;int rand$n or$s=$_};`(echo "\n\n-- ")|cat - $s>>$F`+nan
------------------------------
Date: Tue, 01 May 2001 08:22:43 -0500
From: Michael Vera <mxvera@qwest.com>
Subject: Re: System Call within Daemon - TAKE 2
Message-Id: <3AEEB8A3.1C6BCA12@qwest.com>
Thanks, good answer. Now, here is some code:
print $new_sock "Starting dm_oracle\n";
open(SYS, "$bin_path/start_dm_oracle |" );
SYS->autoflush(1);
while(<SYS>) {
chomp($_);
print $new_sock "$_<br>\n";
}
sleep 5;
print $new_sock " done.<br>\n";
close(SYS);me code:
What I want to do is capture output from the system call, dm_oracle, to
print to the socket. But the system call gains control of my socket
after the parent closes.
If I fork() and exec(), I don't think I will gather any output from the
system call.
If you dont feel that this is perl related, please tell me where I can
post fork() and exec() questions.
Thanks
Mike
Anno Siegel wrote:
> According to Michael Vera <mxvera@qwest.com>:
> > -=-=-=-=-=-
> >
> > Ok, my question didn't get answered, so please let me try again.
>
> It's not a Perl question. Maybe that's why.
>
> > What I need to do is simply fork and exec a system call withOUT the
> > child inheriting ownership of the socket.
>
> [...]
>
> Close the socket in the child. It's a good habit to close un-needed
> filehandles of any sort after a fork.
>
> Anno
------------------------------
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.
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 V10 Issue 812
**************************************