[17965] in Perl-Users-Digest
Perl-Users Digest, Issue: 125 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 23 11:05:43 2001
Date: Tue, 23 Jan 2001 08:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980265916-v10-i125@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Jan 2001 Volume: 10 Number: 125
Today's topics:
Re: [OT] Italic fonts too big <kapur@mts.jhu.edu>
Catching warnings from Getopt::Std <james@NOSPAM.demon.co.uk>
Re: Catching warnings from Getopt::Std <josef.moellers@fujitsu-siemens.com>
Re: Catching warnings from Getopt::Std (Garry Williams)
Re: Catching warnings from Getopt::Std <james@NOSPAM.demon.co.uk>
Re: Catching warnings from Getopt::Std <james@NOSPAM.demon.co.uk>
Re: CHECK CHILD <angenent@kabelfoon.nl>
date and time comparision osieben@gmx.net
Re: date and time comparision (Rafael Garcia-Suarez)
Re: date and time comparision <sebastien.cottalorda@mageos.com>
Re: date and time comparision mosieben@my-deja.com
Re: Directory Recursion Problem. (Mark Jason Dominus)
Re: Directory Recursion Problem. (Mark Jason Dominus)
Re: Directory Recursion Problem. (Tad McClellan)
Re: Directory search without repeating (Mark Jason Dominus)
Re: DOS commands with long directory names (Villy Kruse)
Re: DOS commands with long directory names <bart.lateur@skynet.be>
Re: immortal program : catching signals <c.katzer@gmx.de>
Re: immortal program : catching signals <bernie@fantasyfarm.com>
Re: Is there a fflush? (Mark Jason Dominus)
java stream <ducateg@info.bt.co.uk>
kill -HUP only works once <meisl@amvt.tu-graz.ac.at>
Re: kill -HUP only works once (Anno Siegel)
Re: kill -HUP only works once <meisl@amvt.tu-graz.ac.at>
Newbie question : Read configuration file. <angeraer@hotmail.com>
Re: Newbie question : Read configuration file. <gracenews@optusnet.com.au>
Re: Non Unix user needs help with File::Find sjamiso@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jan 2001 10:14:16 -0500
From: Nevin Kapur <kapur@mts.jhu.edu>
To: dha@panix2.panix.com (David H. Adler)
Subject: Re: [OT] Italic fonts too big
Message-Id: <m3snmajo6v.fsf@fermat.mts.jhu.edu>
[posted and mailed]
On 23 Jan 2001, David H. Adler wrote:
> On 22 Jan 2001 11:51:58 -0500, Nevin Kapur <kapur@mts.jhu.edu>
> wrote:
>>I'm using XEmacs 21.1.13 on Redhat 7.0. I've noticed that my italic
>>fonts are too big compared to regular fonts, i.e. the *-i-* version
>>of a font is bigger that the *-r-* version. This results in a lot a
>>ugliness in general. I was wondering if anyone else has noticed this
>>and if there is a fix. If not, how can I turn off *all* italic
>>fonts?
>
> Why in the world are you asking this in a perl newsgroup?
>
> dha, boggling
It was mistake. I posted a followup to the effect AND canceled the
article too. I apologize again.
--
Nevin
------------------------------
Date: Tue, 23 Jan 2001 14:28:56 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Catching warnings from Getopt::Std
Message-Id: <ant231456c72fNdQ@oakseed.demon.co.uk>
I'm trying to use Getopt::Std to process command line options
with code similar to this:
#!/usr/bin/perl -w
use strict;
use Getopt::Std;
my %options;
getopts('i', \%options);
print "-i ", $options{i} ? "present" : "absent", "\n";
print "\@ARGV is now: @ARGV\n";
However, when an unknown option is encountered Getopt::Std just
removes it from @ARGV and displays the warning "Unknown option: x"
which my program does not know about. I would like my program to be
told when there are unknown options so that I can stop with a suitable
error message. Any ideas anyone?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 15:38:14 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <3A6D9756.ADDACFFC@fujitsu-siemens.com>
James Taylor wrote:
> =
> I'm trying to use Getopt::Std to process command line options
> with code similar to this:
> =
> #!/usr/bin/perl -w
> =
> use strict;
> use Getopt::Std;
> =
> my %options;
> getopts('i', \%options);
> =
> print "-i ", $options{i} ? "present" : "absent", "\n";
> print "\@ARGV is now: @ARGV\n";
> =
> However, when an unknown option is encountered Getopt::Std just
> removes it from @ARGV and displays the warning "Unknown option: x"
> which my program does not know about. I would like my program to be
> told when there are unknown options so that I can stop with a suitable
> error message. Any ideas anyone?
Not being familiar with Getopt::Std, how about declaring _all_ option
letters acceptable and dealing with those you don't want in your
program? This sort of defeats the purpose of Getopt, but then ...
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Tue, 23 Jan 2001 14:52:15 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <zUgb6.22$GF2.1369@eagle.america.net>
On Tue, 23 Jan 2001 14:28:56 +0000, James Taylor
<james@NOSPAM.demon.co.uk> wrote:
[snip]
>getopts('i', \%options);
[snip]
>However, when an unknown option is encountered Getopt::Std just
>removes it from @ARGV and displays the warning "Unknown option: x"
>which my program does not know about.
The getopts() function also returns false. Check it, if you want to
know.
--
Garry Williams
------------------------------
Date: Tue, 23 Jan 2001 14:57:50 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <ant231450064fNdQ@oakseed.demon.co.uk>
In article <3A6D9756.ADDACFFC@fujitsu-siemens.com>, Josef Moellers
<URL:mailto:josef.moellers@fujitsu-siemens.com> wrote:
>
> James Taylor wrote:
> > I would like my program to be told when there are unknown options
> > so that I can stop with a suitable error message. Any ideas anyone?
>
> Not being familiar with Getopt::Std, how about declaring _all_ option
> letters acceptable and dealing with those you don't want in your
> program? This sort of defeats the purpose of Getopt, but then ...
Yes it does - so much so that I'd rather write my own getopt routine.
I am hoping someone will suggest a way of using Getopt::Std and still
being able to discover when it has quietly removed an unknown option,
although I fear this may not be possible.
Any other ideas?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 15:12:42 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <ant231542339fNdQ@oakseed.demon.co.uk>
In article <zUgb6.22$GF2.1369@eagle.america.net>, Garry Williams
<URL:mailto:garry@zvolve.com> wrote:
>
> The getopts() function also returns false.
> Check it, if you want to know.
Interesting. Under what conditions exactly does it return false?
The getopts() return value is not documented, at least not in the
documentation I have. I would be reluctant to rely on an undocumented
feature because it might change in the future.
Looking through the code of Getopt::Std there is no explicit use of
return so I assume from that that the return value is not a well
established thing.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 13:10:27 -0800
From: "GOGAR" <angenent@kabelfoon.nl>
Subject: Re: CHECK CHILD
Message-Id: <94js7r$24nm$1@news.kabelfoon.nl>
----- Original Message -----
From: "Garry Williams" <garry@zvolve.com>
Newsgroups: comp.lang.perl.misc
Sent: Monday, January 22, 2001 9:43 PM
Subject: Re: CHECK CHILD
> On Tue, 23 Jan 2001 06:39:29 -0800, GOGAR <angenent@kabelfoon.nl> wrote:
> >Anybody knows how to see if a fork()'ed child process is still there?
> >thanx
>
> print "alive" if kill 0, $pid;
Actually i tried that, and it always seems to return 1 but looking at the
NT task manager i can see the Thread terminated.
Here's some of my code, i'm trying to do a http request with a timeout.
Often i find that my script hangs waiting for same data which never seems to
come.
so i made it so that just before it does the request it Forks() and the
child process runs a timer.. when the timer gets over 60 i want it to stop
the parent which doesn't really seem to work
i also tried it the other way around.. let the timeout code be the parent
and then on the timeout kill that process
but then i was unable to tell the parent timeout process if the http request
had been completed succesfully
here's some code i made.. the child tries to close <hpSOCK> but that
doesn't appear to work..
die "can't fork: $!" unless defined($kidpid = fork());
if ($kidpid) {
print hpSOCK $tp;
foreach $line (<hpSOCK>){ # This is just some sloppy html stripping
code don't worry about that
if($line=~m/<TR ALIGN="RIGHT"><TH ALIGN="LEFT"><A HREF/){
$index1=index($line," ONMOUSEOUT=\"msg('')\">")+22;
$index2=index($line,"</A> </TH><TD>")-$index1;
$name=substr($line,$index1,$index2);
$line=substr($line,-(length($line)-($index1+$index2)));
$name=~ s/[!-,;-\@\[-^`-`{-˙]//eg;
$line=~s/ / /;
$line=~s/<(.*?)>/ /g;
$line=join(',',split(' ',$line));
print "SD ".$name.",".$line."\n"; # Here the data gets send to another
process
}
}
kill("ALRM", $kidpid); #
}else{
$i=0;
while($i < 60){
$i++;
sleep(1);
}
close(hpSOCK);
exit 0;
}
------------------------------
Date: Tue, 23 Jan 2001 08:05:40 GMT
From: osieben@gmx.net
Subject: date and time comparision
Message-Id: <94je0j$8uk$1@nnrp1.deja.com>
hi,
i am working on a small webboard, to mark the new entries since the
visitors last visit i have to compare the posting time with the one I
have written in the visitors cookies ... but I don't get it working ...
I do something like this ...
$nowtime = $localtime(time); #or similar :-))
# write the cookie with use CGI, works fine here ...
# read the cookie is possible and I get the right date/time
ok ... the next visit I read the cookie into $lastvisit ...
then I want to compare the $lastvisit with the dates of my postings ...
a simple if($lastvisit<$postingdate) ... wont work ...
are there any time comparision methods ?
in C++, I would say, I have to cast my $lastvisit and $postingdate back
into date-time formats ....
please give me some hints ...
I am going crazy on this [ in my opinion too simple problem :-)) ]
thx
olli
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 08:31:29 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: date and time comparision
Message-Id: <slrn96qgbt.4r7.rgarciasuarez@rafael.kazibao.net>
osieben@gmx.net wrote in comp.lang.perl.misc:
> hi,
>
> i am working on a small webboard, to mark the new entries since the
> visitors last visit i have to compare the posting time with the one I
> have written in the visitors cookies ... but I don't get it working ...
> I do something like this ...
>
> $nowtime = $localtime(time); #or similar :-))
^^^
This doesn't even compile.
You meant
$nowtime = localtime(time);
Check the docs for localtime() : this function, in scalar context,
returns a string describing the date and time, e.g. "Tue Jan 23 09:30:54 2001".
This is not a numeric value, thus not suitable for comparisons with the <
and > operators.
If you want the rough time (number of seconds since the epoch), use
the time() function.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 23 Jan 2001 12:58:45 -0000
From: "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com>
Subject: Re: date and time comparision
Message-Id: <94jri7$i7c$1@news5.isdnet.net>
Hi,
You have a module that can do that : Date::Calc (see perldoc Date::Calc)
First you have to split last date and last time respectively in
$last_hour, $last_minute, $last_seconde, $last_day, $last_month,
$last_year
Do the same thing with the curent date and time :
$hour, $minute, $seconde, $day, $month, $year
Then, in your program:
Use Date::Calc qw(Delta_DHMS);
($delta_day,$delta_hour,$delta_minute,$delta_second)=
Delta_DHMS($last_year,$last_month,$last_day,$last_hour,$last_minute,$last_se
cond,
$year,$month,$day,$hour,$minute,$second);
You'll get in $delta_day, $delta_hour,$delta_minute,$delta_second what you
want.
This is one way to manage to have what you want.
Hope this helps.
Sebastien
<osieben@gmx.net> a écrit dans le message : 94je0j$8uk$1@nnrp1.deja.com...
> hi,
>
> i am working on a small webboard, to mark the new entries since the
> visitors last visit i have to compare the posting time with the one I
> have written in the visitors cookies ... but I don't get it working ...
> I do something like this ...
>
> $nowtime = $localtime(time); #or similar :-))
> # write the cookie with use CGI, works fine here ...
> # read the cookie is possible and I get the right date/time
>
> ok ... the next visit I read the cookie into $lastvisit ...
> then I want to compare the $lastvisit with the dates of my postings ...
> a simple if($lastvisit<$postingdate) ... wont work ...
>
> are there any time comparision methods ?
> in C++, I would say, I have to cast my $lastvisit and $postingdate back
> into date-time formats ....
>
> please give me some hints ...
> I am going crazy on this [ in my opinion too simple problem :-)) ]
>
>
> thx
> olli
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 12:57:37 GMT
From: mosieben@my-deja.com
Subject: Re: date and time comparision
Message-Id: <94jv3v$m3s$1@nnrp1.deja.com>
In article <94jri7$i7c$1@news5.isdnet.net>,
"Sébastien Cottalorda" <sebastien.cottalorda@mageos.com> wrote:
> Hi,
>
> You have a module that can do that : Date::Calc (see perldoc
Date::Calc)
> First you have to split last date and last time respectively in
> $last_hour, $last_minute, $last_seconde, $last_day, $last_month,
> $last_year
> Do the same thing with the curent date and time :
> $hour, $minute, $seconde, $day, $month, $year
>
> Then, in your program:
> Use Date::Calc qw(Delta_DHMS);
> ($delta_day,$delta_hour,$delta_minute,$delta_second)=
> Delta_DHMS
($last_year,$last_month,$last_day,$last_hour,$last_minute,$last_se
> cond,
> $year,$month,$day,$hour,$minute,$second);
that look good, even if its a little bit 'boombastic' for my use :0)
but I'll try this ... and I'll take a look at DATE ...
thx
olli
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 10:07:09 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Directory Recursion Problem.
Message-Id: <3a6d57cc.4331$276@news.op.net>
In article <yfZa6.54$LQ1.22667@sapphire.mtt.net>,
Sean Meisner <sdmeisner@SPAMGUARDyahoo.com> wrote:
>The DIRHANDLE you're using to open each directory is a global..
>meaning, each time you recurse it gets overwritten..
In this case it doesn't make a difference.
The problem is with the 'chdir()'.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 23 Jan 2001 10:10:25 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Directory Recursion Problem.
Message-Id: <3a6d5891.434e$92@news.op.net>
Keywords: Sylvania, chlordane, chronic, referential
In article <7a8zo3qvrj.fsf@merlin.hyperchip.com>,
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>What do you mean by 'it fails'? It depends on what you intend it to do
>of course. Please provide more info.
Two or three people responded in this way. But the code had obvious
problems. I don't think the group is well-served by deliberately
obtuse responses.
If your response wasn't deliberately obtuse, perhaps it would have
been more usefu lto wait a day or two before responding, to see if
anyone else picked up on a problem that eluded you.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 23 Jan 2001 14:56:21 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Directory Recursion Problem.
Message-Id: <slrn96qq69.22c.tadmc@tadmc26.august.net>
Chris W <chrisw@dynamite.com.au> wrote:
>
>"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
>news:slrn96otl0.bgr.mgjv@martien.heliotrope.home...
>> I am going to killfile outlook express for good now. I'm just sick of
>> the attitude that comes with it.
>
>This seems to me to be banning the hammer because some people have managed
>to bend nails with it.
It is more like banning a particular kind of hammer.
After <insert threshold value> bent nails, a person may get sick
of bent nails and want to make bending nails a more rare occurence.
At that point there are basically two choices, stop hammering nails
altogether, or avoid the type of hammer that has proven a
proclivity for bending.
Many feel that half a loaf is better than none.
>Of course, you won't be reading this :)
I guess you don't know about advanced scoring newsreaders then.
They are very nice. Look into them should you ever exceed
_your_ bent nail threshold.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Jan 2001 10:18:20 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Directory search without repeating
Message-Id: <3a6d5a6b.4377$303@news.op.net>
In article <3a6c4e80@ant.wmin.ac.uk>,
Ross Clement <clemenr@westminster.ac.uk> wrote:
>I thought it might solve the problem if every file had only one pathname
>that got returned, no matter how you got to the file in the first place.
>I thought that this is what happens with Java.
That's like saying that you want English to be more like French
because in French you don't have to obey the law of gravity.
The OS provides a filesystem; this is the underlying reality. The
programming language interface can describe the reality accurately or
inaccurately. But if the language describes it inaccurately, the
underlying reality is still the same.
On a Unix system, path names are not unique. That is the reality. If
you think that Java guarantees a unique pathname, then either you or
Java is mistaken.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 23 Jan 2001 09:46:12 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: DOS commands with long directory names
Message-Id: <slrn96qkmv.rpd.vek@pharmnl.ohout.pharmapartners.nl>
On Mon, 22 Jan 2001 18:28:42 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
>lbieg@my-deja.com wrote:
>
>>I am trying to execute a DOS command in Perl on Windows NT and ME using
>>the back tick operator where the path contains spaces (ex: "D:\Program
>>Files\...) and I keep getting a bad command or file name error returned.
>>
>>Can anyone tell me if there is any special syntax for this?
>
>Put the file path name between quotes. Something like:
>
> system("\"$longfilename\"");
>
Also, it is a good idea to test if the string is correct by printing it
out.
print("\"$longfilename\"");
This would catch situation where the double quotish interpolation has
swallowed some of your backslashes.
BTW, DOS can accept slashes in pathnames either way, but COMMAND.COM
does not. Thus for system() you do need backslashes between path name
components. That is, of course, if system() calls the external program
using COMMAND.COM instead of directly. Even so, many DOS programs don't
like pathnames with forward slashes either.
Villy
------------------------------
Date: Tue, 23 Jan 2001 10:10:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: DOS commands with long directory names
Message-Id: <g2mq6tocimfitg7a5cshek0mbt3oaeismh@4ax.com>
Villy Kruse wrote:
>BTW, DOS can accept slashes in pathnames either way, but COMMAND.COM
>does not. Thus for system() you do need backslashes between path name
>components. That is, of course, if system() calls the external program
>using COMMAND.COM instead of directly. Even so, many DOS programs don't
>like pathnames with forward slashes either.
tr#/#\\#;
I often construct my file paths with forward slashes, and turn them into
backslashes just before use with the above snippet. Also, with filepaths
as returned from Cwd and File::Find, you practically have to do it.
--
Bart.
------------------------------
Date: Tue, 23 Jan 2001 06:32:27 GMT
From: "Clemens Katzer" <c.katzer@gmx.de>
Subject: Re: immortal program : catching signals
Message-Id: <%z9b6.1991$cF.41882@news1.nokia.com>
vivek@cse.iitd.ernet.in wrote in message <94dq4s$p2c$1@nnrp1.deja.com>...
>hi all,
>
>i wanna write a perl script which will run on X (linux) with root
>owner....i want that a user should not be able to kill the script.....i
If it runs as root, then a user cannot kill it.
>tried using %SIG for the same...but crossing out the window kills the
>signal....i want to catch and ignore all the possible kill signals
>(ofcourse barring a few like -9)....using %SIG for the same didn't
>solved the purpose.....
>
>Please suggest me a solution to trap all the signals and how to write an
>immortal program.............
>
about starting it from a window but it dies when the window is
closed...
are you aware of the "nohup" program?
$ nohup myprog >myprog.out &
will start myprog as backgroundprocess, and its not longer
bound to the terminal.
Otherwise when starting a program e.g. from a prompt , when you
end the prompt shell the program is cleaned up as well.
At least it's what I know...
Good luck.
BR
Cle.
------------------------------
Date: Tue, 23 Jan 2001 09:08:29 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: immortal program : catching signals
Message-Id: <qt3r6tga83rrnu98hm0fe5f9ouct2so7bi@news.supernews.net>
vivek@cse.iitd.ernet.in wrote:
} i wanna write a perl script which will run on X (linux) with root
} owner....i want that a user should not be able to kill the script.....i
} tried using %SIG for the same.....
You haven't made clear what your real goal is here. The 'stated' goal
isn't possible, since users can *always* kill a script [kill -9, at the
least]. You can IGNORE a bunch of signals and go a long way to making a
long-lived process, but if you really need a process that'll run forever, I
think the best plan is NOT to run it from a window but set it up in initab
as a 'respawn'. also, if you run it from initab you won't have (as many)
problems with windows and signals and such. But most of this goes way
beyond Perl matters to questions of Unix, system administration and such..
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Tue, 23 Jan 2001 09:59:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Is there a fflush?
Message-Id: <3a6d5613.4300$37f@news.op.net>
In article <3A6C9AA0.D4AF991F@sgi.com>, Jim Lynch <jwl@sgi.com> wrote:
>I'm using Perl on a Unix system and know about $|, but I'm trying to
>write a log file to other than standard out and would dearly love to
>have an fflush function.
See "Suffering from Buffering"
http://perl.plover.com/FAQs/Buffering.html
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 23 Jan 2001 13:41:33 -0000
From: "Géry" <ducateg@info.bt.co.uk>
Subject: java stream
Message-Id: <94k1rd$6a8$1@pheidippides.axion.bt.co.uk>
Hello,
I have a Perl script which has to pass a hash to Cold Fusion, a package that
is able to gather bits of data from various sources and build HTML code.
Cold Fusion has its house language (CFML, where CF stands for Cold Fusion).
It is ok to stream data from Java to Cold Fusion, but I have not found how
to stream data from Perl.
Therefore, my idea is to pass a hash to a java piece of code (applet,
servlet, bean or whatever) which will in turn transmit it to Cold Fusion.
Does anyone know of a handy module to pass a hash from Perl to Java. Even
better, from Perl to Cold Fusion!
Many thanks in advance,
--
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Géry
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
------------------------------
Date: 23 Jan 2001 13:40:38 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: kill -HUP only works once
Message-Id: <m33dea8mrd.fsf@famvtpc59.tu-graz.ac.at>
I have a very simple perl script:
#! /usr/bin/perl -w
use strict;
use POSIX;
print "Starting demon...\n";
print "Generating child...\n";
my $pid = fork;
if ($pid) {
print "Stopping parent...\n";
exit;
}
unless (defined($pid)) {
die "Error at fork: $!\n";
}
print "Starting new session...\n";
POSIX::setsid() or
die "Cannot start new session: $!\n";
$SIG{USR1} = $SIG{USR2} = sub {print "Got signal...\n";};
$SIG{HUP} = sub {
print "Restarting demon...\n";
exec $0;
};
for (;;) {
}
It should react with a "Got signal..." to a kill -USR1 and kill -USR2
and with a complete restart to a kill -HUP. The kill -HUP works well
if I do it the first time, but the second kill -HUP, which should
restart the process again, does not work. To be honest, it does not do
anything. Can somebody give me a hint?
Best regards,
Christian
--
Christian Meisl <meisl@amvt.tu-graz.ac.at> www.amft.tu-graz.ac.at
Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
--------- The truth is what is; what should be is a dirty lie. ---------
PGP fingerprint: DF48 2503 0411 F0EF 149C 851B 1EF0 72B9 78B6 034A
------------------------------
Date: 23 Jan 2001 13:57:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: kill -HUP only works once
Message-Id: <94k2ko$ema$1@mamenchi.zrz.TU-Berlin.DE>
Christian Meisl <meisl@amvt.tu-graz.ac.at> wrote in comp.lang.perl.misc:
>I have a very simple perl script:
>
>#! /usr/bin/perl -w
>use strict;
>use POSIX;
>
>print "Starting demon...\n";
>print "Generating child...\n";
>my $pid = fork;
>if ($pid) {
> print "Stopping parent...\n";
> exit;
>}
>unless (defined($pid)) {
> die "Error at fork: $!\n";
>}
>print "Starting new session...\n";
>POSIX::setsid() or
> die "Cannot start new session: $!\n";
>
>$SIG{USR1} = $SIG{USR2} = sub {print "Got signal...\n";};
>$SIG{HUP} = sub {
> print "Restarting demon...\n";
> exec $0;
>};
>
>for (;;) {
>}
>
>It should react with a "Got signal..." to a kill -USR1 and kill -USR2
>and with a complete restart to a kill -HUP. The kill -HUP works well
>if I do it the first time, but the second kill -HUP, which should
>restart the process again, does not work. To be honest, it does not do
>anything. Can somebody give me a hint?
Yes. While a process is handling a signal, that signal is blocked.
A process started by exec inherits the list of blocked signals (the
signal mask) from its parent. So what happens is, the process started
by "exec $0" in the signal handler is born with a birth defect: it
is unable to react to a HUP signal.
The solution is either to find out how to unblock a signal (I guess
it's all in POSIX), or to move process creation out of the signal
handler.
I'd prefer the second solution because it also moves the action
out of the signal handler, usually a good idea. Declare a variable
$restart_wanted (say) setting it to 0. In the HUP handler, just
set $restart_wanted = 1. The (currently empty) loop in the
body should now do "exec $0 if $restart_wanted". It would also
be a good idea to throw a "sleep 1" in there to save cpu power.
Sleep will be interrupted when a signal arrives, so no there is
no extra delay with a restart.
Anno
------------------------------
Date: 23 Jan 2001 15:05:53 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: kill -HUP only works once
Message-Id: <m3vgr6748u.fsf@famvtpc59.tu-graz.ac.at>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Yes. While a process is handling a signal, that signal is blocked.
Hmmm, I must admit that I have read about this somewhere,
somewhen... ;-)
Thanks a lot, anyway!!!
Regards,
Christian
--
Christian Meisl <meisl@amvt.tu-graz.ac.at> www.amft.tu-graz.ac.at
Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
---------------- All the easy problems have been solved ----------------
PGP fingerprint: DF48 2503 0411 F0EF 149C 851B 1EF0 72B9 78B6 034A
------------------------------
Date: Tue, 23 Jan 2001 14:45:57 GMT
From: "Andy Geraerts" <angeraer@hotmail.com>
Subject: Newbie question : Read configuration file.
Message-Id: <FOgb6.170$j4.17154@nreader2.kpnqwest.net>
Hello,
I have a few simple perl scripts. They all use variables. Some of these
variables are used over all my scripts and have the same value. What is the
easiest way to read out an configuration file which I would put under /etc?
Is it possible to do some kind of include?
Example config file :
#/etc/config.file
#Comment
Servername=Server.Belgium
I would like to read and set the variable Servername to Server.Belgium.
Thanks a lot!
Andy.
------------------------------
Date: Wed, 24 Jan 2001 01:11:21 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Newbie question : Read configuration file.
Message-Id: <3a6d9f3c$0$16382$7f31c96c@news01.syd.optusnet.com.au>
"Andy Geraerts" <angeraer@hotmail.com> wrote in message
news:FOgb6.170$j4.17154@nreader2.kpnqwest.net...
> Hello,
>
> I have a few simple perl scripts. They all use variables. Some of these
> variables are used over all my scripts and have the same value. What is
the
> easiest way to read out an configuration file which I would put under
/etc?
> Is it possible to do some kind of include?
>
> Example config file :
>
> #/etc/config.file
> #Comment
> Servername=Server.Belgium
>
> I would like to read and set the variable Servername to Server.Belgium.
>
> Thanks a lot!
You could save the variables into a data file, try taking a look at:
http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/index20.html
From what I understand of your problem, the above should be want you need.
Though you will have to get used to accessing these variables from within a
hash, though this does server the purpose of highlighting which variables
were read from the file.
Otherwise you could put your variable statements in a library file, and
"require" this file in your main scripts.
eg:
[commonSettings.pl]
$serverName = "whatever";
[main.pl]
#! /bin/perl
require "commonSettings.pl"; # will need to be in the @INC path.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Tue, 23 Jan 2001 14:24:40 GMT
From: sjamiso@my-deja.com
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <94k46v$qbl$1@nnrp1.deja.com>
Thankyou all for your suggestions.
Shawn J>
Sent via Deja.com
http://www.deja.com/
------------------------------
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 V10 Issue 125
**************************************