Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > -e fails sometimes

Reply
Thread Tools

-e fails sometimes

 
 
Asterbing
Guest
Posts: n/a
 
      03-31-2006
Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime) the
file existence test fails while the path is correct.

For example, here sometimes $fileok becomes zéro, while $file exist on
disk in fact.

if (! -e $file){$fileok = 0;}

Is-it a -e stability issue ?
Does the $file syntax should follow some rules (comes from a form and I
don't escape the "\", is that ok ?) ?

Should I go through open rather than -e ?

What do you think about that ?
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      03-31-2006
Asterbing wrote:
> Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime) the
> file existence test fails while the path is correct.
>
> For example, here sometimes $fileok becomes zéro, while $file exist on
> disk in fact.
>
> if (! -e $file){$fileok = 0;}
>
> Is-it a -e stability issue ?


No, it's a "your code is wrong" issue. But you haven't shown us any
code, so we don't know what's wrong with it.

> Does the $file syntax should follow some rules (comes from a form and I
> don't escape the "\", is that ok ?) ?


What \ are you talking about? Please post a short-but-complete script
that demonstrates the error you're having.

> Should I go through open rather than -e ?


No, since they do very different things.

> What do you think about that ?


I think you should read and follow the Posting Guidelines for this
group.

Paul Lalli

 
Reply With Quote
 
 
 
 
Asterbing
Guest
Posts: n/a
 
      03-31-2006
In article <(E-Mail Removed) .com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> Please post a short-but-complete script
> that demonstrates the error you're having.
>


This code, on some stations, on a LAN under Win32, sometimes, display
"C:\TEST\stats\histo.gif not found" even if the file exists on disk in
this path.

#!/usr/bin/perl
use strict;
print "Content-type: text/html\n\n";
my $file = "C:\\TEST\\stats\\histo.gif";
if (! -e $file){ print $file." not found"; }
else { print $file." found"; }
exit 0;

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      03-31-2006
"Paul Lalli" <(E-Mail Removed)> wrote:

> Asterbing wrote:
>> Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime) the
>> file existence test fails while the path is correct.


....

>> Does the $file syntax should follow some rules (comes from a form and I
>> don't escape the "\", is that ok ?) ?

>
> What \ are you talking about?


Think! Win2K -> \

We expect people posting a message to have some clue, why not the people
who reply?


--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      03-31-2006
John Bokma wrote:
> "Paul Lalli" <(E-Mail Removed)> wrote:
>
> > Asterbing wrote:
> >> Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime) the
> >> file existence test fails while the path is correct.


> >> Does the $file syntax should follow some rules (comes from a form and I
> >> don't escape the "\", is that ok ?) ?

> >
> > What \ are you talking about?

>
> Think! Win2K -> \
>
> We expect people posting a message to have some clue, why not the people
> who reply?


Are you honestly going to tell me that with the post the OP presented
us, we should assume the only \ he had in his string were correct Win2k
directory separators?

I for one chose not to. And the OP posted no code to make me believe
otherwise.

Paul Lalli

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      03-31-2006
"Paul Lalli" <(E-Mail Removed)> wrote:

> John Bokma wrote:
>> "Paul Lalli" <(E-Mail Removed)> wrote:
>>
>> > Asterbing wrote:
>> >> Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime)
>> >> the file existence test fails while the path is correct.

>
>> >> Does the $file syntax should follow some rules (comes from a form
>> >> and I don't escape the "\", is that ok ?) ?
>> >
>> > What \ are you talking about?

>>
>> Think! Win2K -> \
>>
>> We expect people posting a message to have some clue, why not the
>> people who reply?

>
> Are you honestly going to tell me that with the post the OP presented
> us, we should assume the only \ he had in his string were correct
> Win2k directory separators?


Yup, but maybe I am good in reading between the lines. I have to, since
it's what I have been doing for 12+ years when I talk with my customers. I
mean, if you think "newbies" posting here can be unclear...

> I for one chose not to. And the OP posted no code to make me believe
> otherwise.


I think he just did, and again I am right .

--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      03-31-2006
Asterbing <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> In article <(E-Mail Removed) .com>,
> (E-Mail Removed) says...
>> Please post a short-but-complete script
>> that demonstrates the error you're having.
>>

>
> This code, on some stations, on a LAN under Win32, sometimes, display
> "C:\TEST\stats\histo.gif not found" even if the file exists on disk in
> this path.
>
> #!/usr/bin/perl
> use strict;
> print "Content-type: text/html\n\n";
> my $file = "C:\\TEST\\stats\\histo.gif";


my $file = 'C:/TEST/stats/histo.gif';

> if (! -e $file){ print $file." not found"; }
> else { print $file." found"; }
> exit 0;


This is probably a permissions issue.

Sinan
--
A. Sinan Unur <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

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

 
Reply With Quote
 
Tony Curtis
Guest
Posts: n/a
 
      03-31-2006
>> On Fri, 31 Mar 2006 21:25:50 GMT,
>> "A. Sinan Unur" <(E-Mail Removed)> said:


> my $file = 'C:/TEST/stats/histo.gif';


>> if (! -e $file){ print $file." not found"; } else {
>> print $file." found"; } exit 0;


> This is probably a permissions issue.


and/or ownership and/or a race condition with whatever is
creating the GIF. Note it's some kind of web environment
the OP is using.

hth
t
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      03-31-2006
"A. Sinan Unur" <(E-Mail Removed)> wrote:

>> my $file = "C:\\TEST\\stats\\histo.gif";

>
> my $file = 'C:/TEST/stats/histo.gif';


Which is just a different notation (which is easier to type), and not
going to change anything (you know it, I know it, does the OP know it?)


--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-31-2006
Asterbing <(E-Mail Removed)> wrote:
> In article <(E-Mail Removed) .com>,
> (E-Mail Removed) says...
> > Please post a short-but-complete script
> > that demonstrates the error you're having.
> >

>
> This code, on some stations, on a LAN under Win32, sometimes, display
> "C:\TEST\stats\histo.gif not found" even if the file exists on disk in
> this path.
>
> #!/usr/bin/perl
> use strict;
> print "Content-type: text/html\n\n";
> my $file = "C:\\TEST\\stats\\histo.gif";
> if (! -e $file){ print $file." not found"; }


Print the error message, it might be helpful:

if (! -e $file){ print $file." not found: $!"; }

> else { print $file." found"; }
> exit 0;


What do you mean by sometimes? If you put this in a loop and executed it
100000 times on the exact same $file, while nothing else is touching that
file, would it sometimes fail and sometimes succeed? Or does the sometimes
that it fails have a different $file than the sometimes that it succeeds?

Are files being added and removed while all of this going on? If so, how
do you know that the file did in fact exist on disk at the exact instance
that -f was executed?

Xho

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: I find... sometimes it's easy to be myself... sometimes... I find it's better to be somebody else. The Obelisk [7.13.86.42] MCSE 10 06-04-2006 05:40 AM
Firefox locks up on first URL sometimes; Sometimes closes itself Jim Firefox 0 06-28-2005 01:42 PM
? Content Entered in Forms Sometimes Duplicated and Sometimes Not ? Nehmo Sergheyev HTML 1 05-09-2004 07:07 PM
::std sometimes needed, sometimes not Marcin Vorbrodt C++ 24 09-17-2003 03:01 PM
Re: Sometimes ASP.NET does find the dll, sometimes doesn't John Saunders ASP .Net 0 08-28-2003 01:40 PM



Advertisments