[26972] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8922 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 5 18:06:03 2006

Date: Sun, 5 Feb 2006 15:05:07 -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           Sun, 5 Feb 2006     Volume: 10 Number: 8922

Today's topics:
    Re: I just can't get this  global/local/my  stuff <groleau+news@freeshell.org>
    Re: I just can't get this  global/local/my  stuff <groleau+news@freeshell.org>
    Re: Match on x instances of a character <tadmc@augustmail.com>
        Question about abuse of a CGI script <news@chaos-net.de>
    Re: Question about abuse of a CGI script <matthew.garrish@sympatico.ca>
    Re: Question about abuse of a CGI script <news@chaos-net.de>
    Re: Question about abuse of a CGI script <jwkenne@attglobal.net>
    Re: Question about abuse of a CGI script <noreply@gunnar.cc>
    Re: Question about abuse of a CGI script <news@chaos-net.de>
    Re: Question about abuse of a CGI script <1usa@llenroc.ude.invalid>
    Re: Question about abuse of a CGI script <noreply@gunnar.cc>
    Re: Signal handlers, objects and reference counting. xhoster@gmail.com
    Re: Signal handlers, objects and reference counting. (Jamie)
        Why does renaming a file not work when cron'd <slamsworld@shaw.ca>
    Re: Why does renaming a file not work when cron'd <noreply@gunnar.cc>
    Re: Why does renaming a file not work when cron'd <abaugher@esc.pike.il.us>
    Re: Why does renaming a file not work when cron'd <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 05 Feb 2006 23:00:42 GMT
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: I just can't get this  global/local/my  stuff
Message-Id: <usvFf.8699$In4.2911@trnddc06>

Gunnar Hjalmarsson wrote:
> Wes Groleau wrote:
> 
>> my (%DataBase, $The_Key);
>>
>> dbmopen (%DataBase, $GEDCOM . ".DB", 0644)
>>    or die "dbmopen failed ($!) on $GEDCOM.DB\n";
>>
>> [snip]
>>   print $Database{$The_Key};
>>
>> I have compared this version to the earlier version that was working
>> and can't see the difference (except for adding subs that have not yet 
>> been called).
> 
> Perl is case sensitive.

:-)  That's what I get for giving it a stupid name in the first place.
While editing, I accidentally deleted the line and re-typed it.

thanks!

-- 
Wes Groleau
   "Ideas are more powerful than guns,
    We would not let our enemies have guns;
    why should we let them have ideas?"
                                -- Jozef Stalin


------------------------------

Date: Sun, 05 Feb 2006 23:02:18 GMT
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: I just can't get this  global/local/my  stuff
Message-Id: <_tvFf.8703$In4.1603@trnddc06>

Abigail wrote:
> Wes Groleau (groleau+news@freeshell.org) wrote on MMMMDXLI September
> ~~  my (%DataBase, $The_Key);
>              ^ Uppercase B
> ~~  [snip]
> ~~     print $Database{$The_Key};
>                   ^ Lowercase b

Thanks !!
See earlier message for my embarrassed confession.

-- 
Wes Groleau

    "A man with an experience is never
     at the mercy of a man with an argument."
                       -- Ron Allen


------------------------------

Date: Sun, 5 Feb 2006 08:45:50 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Match on x instances of a character
Message-Id: <slrnduc3su.dv3.tadmc@magna.augustmail.com>


[ Please do not top-post.
  Text rearranged into a more sensible order.
]


John Burgess <mordred_au@hotmail.com> wrote:
> Anno Siegel wrote:
>> John Burgess  <mordred_au@hotmail.com> wrote in comp.lang.perl.misc:

>>>Problem: Iterating through a list of newsgroups and matching only those 
>>>with 2 .'s in the name.

>> However, the easiest (and fastest) way of counting characters is the
>> tr/// operator:
>> 
>>     if ( tr/.// == 2 ) { #...


Note that there *are no* regular expressions used in Anno's suggestion.


> Part of the reason for finding the correct match regexp was 
> to test for speed, which I will still test. 


Sounds like premature optimization to me...


> The other thing is I want to 
> use this in a grep and I'm not sure the tr can be used economically in 
> this context? 


The docs for grep() say that it can take any EXPRession.

tr/// is an expression.

   my @two_dot_groups = grep tr/.// == 2, @newsgroups;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 5 Feb 2006 18:03:21 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Question about abuse of a CGI script
Message-Id: <slrnducbup.rv9.news@maki.homeunix.net>

hello together,

I had a CGI Skript on my mothers website to send email from a html form
(method post) for about two yaers.

The script was quite simple and had no checking of the User input
implemented.
When I wrote the script two years ago, I didn't even know that this is
neccesary.
I used Mail::Mailer to send the input from the form in a nicely formated
html email to my mother's email address.

Now the script was abused by a spammer who sent at least 6000 (probably
far more) spam emails.

I found *perldoc -q "How do I make sure"* which will enable me to secure
my script, but I also have another question:

How can I  recieve the exact input of the spammer to my form as email
without giving him the chance to abuse my script. I want to understand,
what he did and how it worked.

Any information will be appreciated.
Thanks in advance

Best regards
Martin


-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


------------------------------

Date: Sun, 5 Feb 2006 12:41:55 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Question about abuse of a CGI script
Message-Id: <CNqFf.821$J%6.21821@news20.bellglobal.com>


"Martin Kissner" <news@chaos-net.de> wrote in message 
news:slrnducbup.rv9.news@maki.homeunix.net...
> hello together,
>
> I had a CGI Skript on my mothers website to send email from a html form
> (method post) for about two yaers.
>
> The script was quite simple and had no checking of the User input
> implemented.
> When I wrote the script two years ago, I didn't even know that this is
> neccesary.

That's a scary statement to confess to... : )

>
> How can I  recieve the exact input of the spammer to my form as email
> without giving him the chance to abuse my script. I want to understand,
> what he did and how it worked.
>

It would seem that if you have really secured your script, the person's 
method would no longer work. Usually there is nothing special about what the 
spammers do. They rely on you using cheap scripts like the one's you get 
from Matt's archive, which they can then easily exploit because the source 
code is free to look over and the bugs with it well known. Or they look for 
obvious exploits like the ability to cc the email to someone and then flood 
that field with email addresses.

I don't know how to answer your question except to say you should log every 
request to that form with all the parameters submitted until the spammer 
hits you again. I don't see how you can distinguish the spammer and allow 
that person to run your script but not really execute it, which it sounds 
like you want. You might also want to look into measures like captchas, 
which will foil all but the most determined hackers.

Matt 




------------------------------

Date: Sun, 5 Feb 2006 20:34:25 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Question about abuse of a CGI script
Message-Id: <slrnduckq1.s8a.news@maki.homeunix.net>

Matt Garrish wrote :
>
> "Martin Kissner" <news@chaos-net.de> wrote in message 
> news:slrnducbup.rv9.news@maki.homeunix.net...
>> hello together,
>>
>> I had a CGI Skript on my mothers website to send email from a html form
>> (method post) for about two yaers.
>>
>> The script was quite simple and had no checking of the User input
>> implemented.
>> When I wrote the script two years ago, I didn't even know that this is
>> neccesary.
>
> That's a scary statement to confess to... : )

Well, I am an autodidact and sometimes things must be learned the hard
way ;-)
>>
>> How can I  recieve the exact input of the spammer to my form as email
>> without giving him the chance to abuse my script. I want to understand,
>> what he did and how it worked.
>>
>
> It would seem that if you have really secured your script, the person's 
> method would no longer work.

Up to now I did not really secure the script but I have put in some
filters to prevent the person's method from working. I think this is is
a large scale spammer since he sends mail to far more than 100.000
recipients.

> Usually there is nothing special about what the 
> spammers do. They rely on you using cheap scripts like the one's you get 
> from Matt's archive, ...

or mine *g*

> ... which they can then easily exploit because the source 
> code is free to look over and the bugs with it well known. Or they look for 
> obvious exploits like the ability to cc the email to someone and then flood 
> that field with email addresses.

Yes, I think so.
Two days before the attack I reallized 5 emails with strange looking
values in the form fields. I afterwards could extract a single Bcc
address which I suppose is controlled by the spammer and is used to
report exploitable mail forms.

> I don't know how to answer your question except to say you should log every 
> request to that form with all the parameters submitted until the spammer 
> hits you again. I don't see how you can distinguish the spammer and allow 
> that person to run your script but not really execute it, which it sounds 
> like you want. You might also want to look into measures like captchas, 
> which will foil all but the most determined hackers.

Distiguishing the spammer at this point is no problem.
As soon as I rename my email form back and open the filters I
implemented, he hits me over and over again from different IP addresses.
I could collect 10thousands of email addresses from his list because they
are listed in the first input field of my form.

I have already removed any variables from the part of my script which
sets the mailheaders but still he gets through.

What I want is to execute a script which enables me to analyse the
method the spammer uses in order to learn how this works - not because I
want to redo it, but I am interested.
If possible I would like to read the exact code (and other input) he
writes to the input fields of my form.

Best regards
Martin 

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


------------------------------

Date: Sun, 05 Feb 2006 14:42:08 -0500
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Question about abuse of a CGI script
Message-Id: <oysFf.697$qW1.109@fe08.lga>

Martin Kissner wrote:
> hello together,
> 
> I had a CGI Skript on my mothers website to send email from a html form
> (method post) for about two yaers.
> 
> The script was quite simple and had no checking of the User input
> implemented.
> When I wrote the script two years ago, I didn't even know that this is
> neccesary.
> I used Mail::Mailer to send the input from the form in a nicely formated
> html email to my mother's email address.
> 
> Now the script was abused by a spammer who sent at least 6000 (probably
> far more) spam emails.

A device that has worked for me to foil robot spammers is simply to 
leave the submit button out of the HTML and create it instead at onload 
time, using JavaScript. It won't stop a human, but generally stymies robots.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


------------------------------

Date: Sun, 05 Feb 2006 20:44:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Question about abuse of a CGI script
Message-Id: <44n2rbF31605U1@individual.net>

Martin Kissner wrote:
> What I want is to execute a script which enables me to analyse the
> method the spammer uses in order to learn how this works - not because I
> want to redo it, but I am interested.

If you post the (relevant part of the) script here, somebody will 
probably be able to tell you what the problem is.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Sun, 5 Feb 2006 23:24:25 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Question about abuse of a CGI script
Message-Id: <slrnducuop.s8a.news@maki.homeunix.net>

Gunnar Hjalmarsson wrote :
> Martin Kissner wrote:
>> What I want is to execute a script which enables me to analyse the
>> method the spammer uses in order to learn how this works - not because I
>> want to redo it, but I am interested.
>
> If you post the (relevant part of the) script here, somebody will 
> probably be able to tell you what the problem is.

Yes, absolutely.
I did not do so in the first place for two reasons.

1. I am not really sure which part is relevant.
2. It took me some time to simplify the script and remove several
conditions etc.


I hoped someone might be able to point me to the right direction without
seeing code.

Now her comes the code.
And, yes I already know that it was bad to process the user input
unchecked.
Thanks for looking at the code, I hope i have provided appropriate
information.

Best regards
Martin

--- code ---

my %userinput;
sub process {
	%userinput = parse_input($_[1]);
	generate_output() if send_mail();
}

sub send_mail {
    use Mail::Mailer;
    my $mailer  = Mail::Mailer->new;
    $mailer->open ({
			To      => 'mail@thedomain.tld',
# The spammers script still worked after I had replaced the variables
# with fixed values
            From    => "$userinput{name} <$userinput{from}>",
            'Content-Type'  => 'text/html',
            Subject => "My Subject",
        });
	print $mailer <<"END"
	<html>...
	<br>$userinput{name}
	<br>$userinput{otherfield}
	...</html>
END
	$mailer->close;
}

sub parse_input {
# I hope I did not mess this up when I simplified it
    my $input = shift;
    my %cgihash;
        
    my @pairs =split(/&/,$input);
    foreach my $data (@pairs) {   
        $data =~ s/\+/ /go;
        ($key, $value) = split(/=/,$data);
        $key =~ s/\%(..)/pack("c",hex($1))/ge;
        $value =~ s/\%(..)/pack("c",hex($1))/ge;
		$cgihash{$key} = $value;
    }
	return %cgihash;
}

--- code ---

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


------------------------------

Date: Sun, 05 Feb 2006 22:34:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Question about abuse of a CGI script
Message-Id: <Xns9761B2E5122B3asu1cornelledu@127.0.0.1>

Martin Kissner <news@chaos-net.de> wrote in
news:slrnducuop.s8a.news@maki.homeunix.net: 

> Gunnar Hjalmarsson wrote :
>> Martin Kissner wrote:
>>> What I want is to execute a script which enables me to analyse the
>>> method the spammer uses in order to learn how this works - not
>>> because I want to redo it, but I am interested.
>>
>> If you post the (relevant part of the) script here, somebody will 
>> probably be able to tell you what the problem is.
> 
> Yes, absolutely.
> I did not do so in the first place for two reasons.
> 
> 1. I am not really sure which part is relevant.
> 2. It took me some time to simplify the script and remove several
> conditions etc.

Have you seen the posting guidelines? Especially the part about posting 
code?

> I hoped someone might be able to point me to the right direction
> without seeing code.

How? Are we mindreaders?

use strict;
use warnings;

missing (oh, and don't tell me you did not include those because someone 
told you they would slow your script down).

> my %userinput;
> sub process {
>      %userinput = parse_input($_[1]);
>      generate_output() if send_mail();
> }
> 
> sub send_mail {
>     use Mail::Mailer;
>     my $mailer  = Mail::Mailer->new;
>     $mailer->open ({
>                To      => 'mail@thedomain.tld',
> # The spammers script still worked after I had replaced the variables
> # with fixed values
>             From    => "$userinput{name} <$userinput{from}>",

So, what happens if $userinput{name} contains:

aaa@example.com,\naab@example.com,\naac@example.com ...

>             'Content-Type'  => 'text/html',
>             Subject => "My Subject",
>         });
>      print $mailer <<"END"
>      <html>...
>      <br>$userinput{name}
>      <br>$userinput{otherfield}
>      ...</html>

I thought you used templates and such.

> END
>      $mailer->close;
> }
> 
> sub parse_input {
> # I hope I did not mess this up when I simplified it
>     my $input = shift;
>     my %cgihash;
>         
>     my @pairs =split(/&/,$input);
>     foreach my $data (@pairs) {   
>         $data =~ s/\+/ /go;

Why the 'o' switch?


>         ($key, $value) = split(/=/,$data);
>         $key =~ s/\%(..)/pack("c",hex($1))/ge;
>         $value =~ s/\%(..)/pack("c",hex($1))/ge;
>           $cgihash{$key} = $value;
>     }
>      return %cgihash;

No comment.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Sun, 05 Feb 2006 23:50:39 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Question about abuse of a CGI script
Message-Id: <44ndndF2f1erU1@individual.net>

Martin Kissner wrote:
> 
>     $mailer->open ({
> 			To      => 'mail@thedomain.tld',
> # The spammers script still worked after I had replaced the variables
> # with fixed values
>             From    => "$userinput{name} <$userinput{from}>",

What would happen if $userinput{name} consists of the string that this 
expression results in:

qq|faked\@example.com\nCc: victim1\@example.com, victim2\@example.com,|

?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: 05 Feb 2006 19:39:36 GMT
From: xhoster@gmail.com
Subject: Re: Signal handlers, objects and reference counting.
Message-Id: <20060205144146.334$6c@newsreader.com>

nospam@geniegate.com (Jamie) wrote:
> Hello Newsgroup,
>
> Say I've got an object that needs to be notified on SIGCONT
> (or PIPE or ...)
>
> I can do this:
>
>         my($self) = shift;
>         $SIG{CONT} = sub {
>                 $self->do_whatever();
>         };
>
> But then.. when the object goes out of scope, it never gets cleaned
> up because of the $self in the closure

Isn't this a good thing?  As long as the signal handler is set up to
call do_whatever, shouldn't it be able to make that call?  How can it do
that other than by keeping the object alive?  If you set the SIG{CONT} with
"local", then it would automatically destroy the sub-ref, which would then
lead to the destruction of the $self object, after $self goes out of
lexical scope and the SIG localization goes out of dynamic scope.

But if that isn't what you want, then use Scalar::Util::weaken.


use Scalar::Util qw(weaken);
{
  my $self=new foo;
  {my $dummy=$self; weaken $dummy;  $SIG{CONT}=sub { $dummy->whatever() }};
  warn "About to go out of scope in $$"; sleep 5;
};
warn "self just went out of scope";
package foo;
sub new { bless {}};
sub DESTROY {warn "Destroying @_"};
sub whatever {warn "whatever"};
__END__


About to go out of scope in 28684 at - line 6.
Destroying foo=HASH(0x804d41c) at - line 11.
self just went out of scope at - line 8.

Notice that it is destroyed when $self goes out of scope, rather than
during global destruction.


> (To say nothing of other things
> that might want to be alerted as well)

Saying something about it is not a very good way to say nothing
about it. :)  This makes me think the problem is substantially more
complicated than you are describing, which means the answer may be too.


> Best I can do is have a global
> variable with $self in it, and a cleanup method that determines if it's
> the same as global, then undef's it.

If you have to decide in your code when to clean it up, why not just unset
the sig-handler at that point, rather than undef something else?

>
> What is a good, standard way of dealing with this?
>
> On that note, what is a good way of finding memory leaks?

>
> I've got quite a number of modules with circular references (By design,
> they need to be that way unfortunately.)

Does each circularity lie entirely within one module, or does the
circularity span modules?  If the former, test each module independently,
using weaken to bypass the circularity.  If the latter, then good luck to
you and seriously consider redesigning.

>
> What I'd like is a tool that'll show me how many (and ideally where/who)
> is holding on to a given object so I know where to free it.

I don't see how the described tool will help you obtain the stated goal.
As the programmer/designer of circular references, only you can know where
they ought to be freed, perl cannot tell you that.   It seems you need help
figuring *how* to free it, not where to free it.  (Or perhaps you need help
figuring out how to design it so that it is freed automatically, which
still not the same thing as where to free it.)

>
> Know any good tricks for reference tracking and deleting?

sub DESTROY {warn "I'm being destroyed @_"}

> Not so much
> modules, just handy debugging tricks to track them. (What is the
> reference count on variable $foo and ideally, who holds it?)

To find circular refs, you can do something like this:

 ....
sub new {
  my $foo = bless {}; # or whatever the constructor would be
  push @::objects, $foo;
  Scalar::Util::weaken $::objects[-1];
  return $foo;
};
 ....
use Data::Dumper;
END {
  warn "Ending with the following un-cleaned up objects:";
  print Dumper [grep defined, @::objects];
};

By inspecting the Data::Dumper results, you should be able to figure
where the circularity lies.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Sun, 05 Feb 2006 21:37:12 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Signal handlers, objects and reference counting.
Message-Id: <Lucy113917387575540xb45668@localhost>

In: <20060205144146.334$6c@newsreader.com>, xhoster@gmail.com wrote:
>nospam@geniegate.com (Jamie) wrote:
>Isn't this a good thing?  As long as the signal handler is set up to
>call do_whatever, shouldn't it be able to make that call?  How can it do
>that other than by keeping the object alive?  If you set the SIG{CONT} with
>"local", then it would automatically destroy the sub-ref, which would then
>lead to the destruction of the $self object, after $self goes out of
>lexical scope and the SIG localization goes out of dynamic scope.

Typically, I'll have something like:

sub main {
	$obj = new App($conf);
	$obj->run();
	$obj->finish();
}

I could, I suppose, localize everything in main() (and this seems to be
the most logical approach) but.. it seems there ought to be a better way.

Some day, I might want:

package Bigger::Unrelated::App;

sub run {
	... $mini->run();
	... $bigger-run();
}

sub finish {
	... $mini->finish();
	... $bigger->finish()
}

1;

Which would break the local stuff.

>But if that isn't what you want, then use Scalar::Util::weaken.

Thanks for the tip.

>Saying something about it is not a very good way to say nothing
>about it. :)  This makes me think the problem is substantially more
>complicated than you are describing, which means the answer may be too.

It is complex. The signal handlers are the worst. It really does start
to make me think a package implementing a "listener" type pattern
is the way to go on that. (Alas, then every %SIG spot will change..)

I have multiple "chunks" that really ought to be told when the terminal
size changes. These go in and out of scope ofen, when they're destroyed,
they don't need to know. (Maybe there's a way around that..) 

>Does each circularity lie entirely within one module, or does the
>circularity span modules?  If the former, test each module independently,
>using weaken to bypass the circularity.  If the latter, then good luck to
>you and seriously consider redesigning.

The circularity is basically all over the place.

Mainly with the $app object, which contains, among other things, the
configuration, access to cached objects which also contain a ref to it., things
like that. The plan was to pass this around so everything else gets access to
stuff it needs w/out storing any global variables. (or, very minimal globals)
One could, at least in theory, have multiple instances of the same application
set with different configurations this way. (in practice... not so much)

The other circular reference  (the one I need to watch carefully) is 
a parent-child relation. Each child should know it's parent, the parent
needs to know who it's children are, at worse cases, there may be multiple
collections of 50,000 such objects. There is a way around this, but I suspect
it would cause more problems later.

>> Know any good tricks for reference tracking and deleting?
>
>sub DESTROY {warn "I'm being destroyed @_"}

That, so far, seems to be the best trick yet. :-)

>To find circular refs, you can do something like this:
>
>....
>sub new {
>  my $foo = bless {}; # or whatever the constructor would be
>  push @::objects, $foo;
>  Scalar::Util::weaken $::objects[-1];
>  return $foo;
>};
>....
>use Data::Dumper;
>END {
>  warn "Ending with the following un-cleaned up objects:";
>  print Dumper [grep defined, @::objects];
>};
>
>By inspecting the Data::Dumper results ... 

Data::Dumper is an extremely useful tool, but... some of the structures
are nested such that even Data::Dumper has a hard time with them. (I suspect
it's just the sheer size of some of them)

Jamie
-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


------------------------------

Date: Sun, 05 Feb 2006 15:05:28 GMT
From: "gd" <slamsworld@shaw.ca>
Subject: Why does renaming a file not work when cron'd
Message-Id: <YuoFf.559763$ki.521139@pd7tw2no>

Hello all

I have created a small script to go to the internet and get some data I am
interested in and save it to a linux machine

Can anyone tell me why the script will rename and save the file properly
when I run it from the command line but when I cron it it does not

the line of code to rename the file is

rename("wind.png","$data.png");

thanks

gd





------------------------------

Date: Sun, 05 Feb 2006 16:20:47 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Why does renaming a file not work when cron'd
Message-Id: <44mjdvF2u141U1@individual.net>

gd wrote:
> Can anyone tell me why the script will rename and save the file properly
> when I run it from the command line but when I cron it it does not

Yes, Perl can.

     rename 'wind.png', $data.png or die $!;

> the line of code to rename the file is
> 
> rename("wind.png","$data.png");

See "perldoc -q quoting"

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Sun, 05 Feb 2006 10:08:56 -0600
From: Aaron Baugher <abaugher@esc.pike.il.us>
Subject: Re: Why does renaming a file not work when cron'd
Message-Id: <86slqxdbzb.fsf@cail.baugher.pike.il.us>

"gd" <slamsworld@shaw.ca> writes:

> Can anyone tell me why the script will rename and save the file
> properly when I run it from the command line but when I cron it it
> does not

When things work from the command line but not from cron, it usually
means the cron job is running with different permissions or a
different $PATH than you have when you're logged in.  So first, are
you running it as the same user as the owner of the cron job?  If so,
do you call any external programs or open any files without using the
full path?

> the line of code to rename the file is
>
> rename("wind.png","$data.png");

rename("wind.png","$data.png") or die $!;

Are you sure your script has already chdir'd to the right place before
doing this?


-- 
Aaron -- aaron_baugher@yahoo.com
         http://360.yahoo.com/aaron_baugher


------------------------------

Date: Sun, 05 Feb 2006 16:41:32 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why does renaming a file not work when cron'd
Message-Id: <akacu1ph8o6r9nkvqguem3q1i8ea0m9mfo@4ax.com>

gd wrote:

>Can anyone tell me why the script will rename and save the file properly
>when I run it from the command line but when I cron it it does not
>
>the line of code to rename the file is
>
>rename("wind.png","$data.png");

Just a guess: the working directory of the script isn't the same when
run from cron.

Either that, or it's a different user, which lacks the proper
permissions.

-- 
	Bart.


------------------------------

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 V10 Issue 8922
***************************************


home help back first fref pref prev next nref lref last post