File::Find problem on windows+apache+activePerl

K

Koolrans

Hi All,

I am trying to use file::find on windows + activeperl + apache. I have
a script which should ftp files from a certain folder on a windows
share folder on another machine to a different server. This script can
run in two ways. One is via command line and another is from the web
server (Apache).

The one from command line works fine. It does ftp all the files from
the windows share on remote machine to another machine. The problem
occurs when the script runs from apache. When I open the script from
web browser, it does execute but file::find does not call my provided
function for any of the scripts in the directory. I guess, it does not
find any files on the windows share. Does anyone have any idea as to
why this would happen.

Thanks,

Koolrans
 
J

Jürgen Exner

Koolrans said:
The one from command line works fine. It does ftp all the files from
the windows share on remote machine to another machine. The problem
occurs when the script runs from apache. When I open the script from
web browser,

I suggest to follow the advise that is given in the FAQ.

"perldoc -q 500":
"My CGI script runs from the command line but not the browser."

jue
 
K

Koolrans

Hi,

Thanks for the reply. I did try the FAQ. It is different in my error in
the sense that I do not get any 500 or server side errors. In my
script, the script does work but the file::find does not find any list
of files when called from browser.
Thanks,
Koolrans
 
I

Ian Wilson

Koolrans said:
Thanks for the reply.

http://groups.google.com/googlegroups/posting_style.html#summarize
(use the "Options" link at the top of GG, not the "reply" at the bottom)
I did try the FAQ. It is different in my error in
the sense that I do not get any 500 or server side errors. In my
script, the script does work but the file::find does not find any list
of files when called from browser.

It seems likely to me that you are not checking the responses of some
subroutine/method call for possible error conditions/messages. Without
seeing your code, it is nearly impossible to help.

See "Provide enough information" in the posting guidelines posted here
every few days. If you read that and act on it, I'm sure you'll get your
problem fixed.
 
J

Jürgen Exner

Koolrans said:
Thanks for the reply. I did try the FAQ. It is different in my error
in the sense that I do not get any 500 or server side errors. In my
script, the script does work but the file::find does not find any list
of files when called from browser.

A wild shot in the dark, but I bet you are not using
.... or die ("Some useful error message");
when opening your files or you are not dieing if File::Find returns with an
error code.

Which simply means that your Perl script is masking the error instead of
letting the CGI server handle the error where it would have caused a 500.

jue
 
P

Paul Lalli

Koolrans said:
Thanks for the reply. I did try the FAQ.

Who are you thanking? What reply? What FAQ?

Please quote an appropriate amount of context when posting a reply to
Usenet.
It is different in my error in
the sense that I do not get any 500 or server side errors. In my
script, the script does work but the file::find does not find any list
of files when called from browser.

I find those two sentences contradictory. Just because your errors are
not compile-time errors does not mean you are not getting errors.

The fact remains that your script "works" on the command line but does
not "work" when executed from the browser.

90% of the time, this is due to permissions problems. Whatever user
you're running as from the command line has certain permissions to the
directory structure that the user that the webserver is executing the
CGI as does not have.

Are you checking all your file I/O operations for errors? Are you
dying on errors? Are you including the operating system's last error
variable ($!) in those die messages?

It's time for you to show some code.

BTW, you should probably read the Posting Guidelines for this group
before posting again.

Paul Lalli
 
T

Tintin

Koolrans said:
Hi All,

I am trying to use file::find on windows + activeperl + apache. I have
a script which should ftp files from a certain folder on a windows
share folder on another machine to a different server. This script can
run in two ways. One is via command line and another is from the web
server (Apache).

The one from command line works fine. It does ftp all the files from
the windows share on remote machine to another machine. The problem
occurs when the script runs from apache. When I open the script from
web browser, it does execute but file::find does not call my provided
function for any of the scripts in the directory. I guess, it does not
find any files on the windows share. Does anyone have any idea as to
why this would happen.

The problem is occuring around line 100.
 
T

Tad McClellan

Koolrans said:
Hi,

Thanks for the reply. I did try the FAQ. It is different in my error in
the sense that I do not get any 500 or server side errors. In my
script, the script does work but the file::find does not find any list
of files when called from browser.


Are you giving File::Find (not file::find) relative paths
to the directories?

Maybe your current directory isn't what you think it is...
 
K

Koolrans

Thanks for the reply. I did try the FAQ.
Who are you thanking? What reply? What FAQ?

My bad. Being my first time, I used reply instead of options->reply. So
the reply only made it to the author.
Are you checking all your file I/O operations for errors? Are you
dying on errors? Are you including the operating system's last error
variable ($!) in those die messages?

It's time for you to show some code.

Here is how I use the function.

@src_dir = "\\\\testnetwork\\filesToBeUploaded\\linux"
print "@src_dir";

find(\&processFiles, "@src_dir") or die ("Can't fetch information from
the find command: $! $@\n");

This works fine from commandline and gives an error when run from
apache. The print is successful and I can see the desired value in the
browser. The following error is logged into the log.

[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Can't stat
\\\\testnetwork\\filesToBeUploaded\\linux: No such file or directory,
referer: http://test2-2k/Test/
[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] at
commonFuncs.pl line 29, referer: http://test2-2k/Test/
[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Use of
uninitialized value in concatenation (.) or string at commonFuncs.pl
line 29., referer: http://test2/Test/
[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Can't fetch
information from the find command: No such file or directory , referer:
http://test2-2k/Test/

As evident, it is an escape character issue but am new to perl. So do
not have an idea.

Can somebody tell me how to fix this.

Thanks,
Koolrans
 
A

A. Sinan Unur

My bad. Being my first time, I used reply instead of options->reply.
So the reply only made it to the author.

Please do not snip attributions. Please trim the post appropriately.

That would have been an excellent thing to do the first time you posted.
Here is how I use the function.

use strict;
use warnings;

missing.
@src_dir = "\\\\testnetwork\\filesToBeUploaded\\linux"

use File::Spec::Functions qw( catfile );

my $src_dir = catfile qw( \\\\Aardvark filestobeuploaded linux );
print "@src_dir";

It is an error to output anything in a CGI script before headers are sent.
find(\&processFiles, "@src_dir")

find(\&processFiles, $src_dir)
[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Can't stat
\\\\testnetwork\\filesToBeUploaded\\linux: No such file or directory,

That's weird when I run your code, the error I get is:

D:\Home\asu1\UseNet\clpmisc> r
Can't stat \\testnetwork\filesToBeUploaded\linux: ...

How can there be four slashes above? There must be some relevant code you
are not showing us.

Please come up with a short and complete script others can run.

Now, to be able to run the following script on my local network, I had to
not only create the appropriate share, but also poke a hole through the
Symantec Firewall. So, it looks like your issue does not have much to do
with Perl, but with the configuration of your OS, web server, firewall
etc.

#!/usr/bin/perl

use warnings;
use strict;

use File::Find;
use File::Spec::Functions qw( catfile );

my $src = catfile qw(\\\\Aardvark vim);

find(\&process_files, $src);

sub process_files {
print;
}

__END__

The posting guidelines explain how to use an effective quoting style.
 
J

Jürgen Exner

Koolrans said:
Here is how I use the function.

@src_dir = "\\\\testnetwork\\filesToBeUploaded\\linux"
print "@src_dir";

Yikes. You are suffering from leaning toothpick syndrom.
And why an array when you are assigning only one string?
And that on Linux. I don't know for sure, but his line smells fishy to me.
find(\&processFiles, "@src_dir") or die ("Can't fetch information from
the find command: $! $@\n");

This works fine from commandline and gives an error when run from
apache. The print is successful and I can see the desired value in the
browser. The following error is logged into the log.

[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Can't stat
\\\\testnetwork\\filesToBeUploaded\\linux: No such file or directory,

Well, I would guess: a permission problem. Or a problem with using the wrong
path separator.
As evident, it is an escape character issue

Well, maybe or maybe not.
First of all even on Windows you happily use normal forward slashes. Then
you don't get the leaning toothpick syndrom.
Second if you do want to have backslashes and you have a literal string and
don't want it stringified then use single quotes instead of double quotes.
Then even the backslash looses its special meaning and you don't have to
escape it.

$src_dir = '//testnetwork/filesToBeUpLoaded/linux';

jue
 
K

Koolrans

Thanks everyone for you help. I was able to find the problem. It was
with the user account assigned to Apache web server. For some reason
windows was not assigning the desired permissions to Apache. It ran
from command line because perl got the permissions correctly. I gave
admin rights to apache service and it worked. Now, I shall carefully
reduce the permissions to find out more but now it works.

Also, I used File::Spec::Functions as advised and removed the array.

I shall definitely improve on my posting style next time.

Regards,
Koolrans



A. Sinan Unur said:
My bad. Being my first time, I used reply instead of options->reply.
So the reply only made it to the author.

Please do not snip attributions. Please trim the post appropriately.

That would have been an excellent thing to do the first time you posted.
Here is how I use the function.

use strict;
use warnings;

missing.
@src_dir = "\\\\testnetwork\\filesToBeUploaded\\linux"

use File::Spec::Functions qw( catfile );

my $src_dir = catfile qw( \\\\Aardvark filestobeuploaded linux );
print "@src_dir";

It is an error to output anything in a CGI script before headers are sent.
find(\&processFiles, "@src_dir")

find(\&processFiles, $src_dir)
[Mon Feb 27 13:06:02 2006] [error] [client 10.2.20.109] Can't stat
\\\\testnetwork\\filesToBeUploaded\\linux: No such file or directory,

That's weird when I run your code, the error I get is:

D:\Home\asu1\UseNet\clpmisc> r
Can't stat \\testnetwork\filesToBeUploaded\linux: ...

How can there be four slashes above? There must be some relevant code you
are not showing us.

Please come up with a short and complete script others can run.

Now, to be able to run the following script on my local network, I had to
not only create the appropriate share, but also poke a hole through the
Symantec Firewall. So, it looks like your issue does not have much to do
with Perl, but with the configuration of your OS, web server, firewall
etc.

#!/usr/bin/perl

use warnings;
use strict;

use File::Find;
use File::Spec::Functions qw( catfile );

my $src = catfile qw(\\\\Aardvark vim);

find(\&process_files, $src);

sub process_files {
print;
}

__END__

The posting guidelines explain how to use an effective quoting style.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top