# SEARCH THE LOG FILE FOR THE REQUESTED INFO
$logfile = "\\\\machine_name\\path\\to\\logfile.log";
# $logfile = "E:\\path\\to\\logfile.log";
open (LOG, "$logfile") || die "Cannot open $logfile. $!";
When this is run, the script dies with the Invalid Argument error.
I've tried both ways of getting to the path as shown above. Does
anyone have any insight into what might be the problem. FWIW, the
drive I'm trying to read from is being accessed through MS Networking.
Again, I'm not very familiar with perl on MS systems so this may be
part of the problem.
Thanks for any help anyone can offer.
Michael Nass
Web Developer
then...@hotmail.com
What do you think "this" is?
> This may be part of the reason as I don't totally know how to specify
> where a file is located for Win systems. Code below:
>
> # SEARCH THE LOG FILE FOR THE REQUESTED INFO
> $logfile = "\\\\machine_name\\path\\to\\logfile.log";
> # $logfile = "E:\\path\\to\\logfile.log";
>
> open (LOG, "$logfile") || die "Cannot open $logfile. $!";
>
> When this is run, the script dies with the Invalid Argument error.
> I've tried both ways of getting to the path as shown above. Does
> anyone have any insight into what might be the problem.
Well the sharename is missing in the UNC path but this is probably an
artifact. I can see nothing wrong with the above code.
> FWIW, the drive I'm trying to read from is being accessed through MS
> Networking.
PSI::ESP tells me that the Perl script is not being excuted directly
in an interactive Windows session but rather is being called by some
sort of server daemon (e.g. a web server) and that the session
credentials with which the server daemon spawns sub-processes do not
grant relevant access to the network.
If this is the case then this is a question about configuring the
server in question and nothing to do with Perl.
One would hope in such a case to get "access denied" rather than
"invalid argument" but I wouldn't be supprised if Win32 is returning
the wrong error.
Can you reproduce these symptoms in a Perl script executed from the
command line?
> Again, I'm not very familiar with perl on MS systems so this may be
> part of the problem.
I doubt that the "perl on" bit is significant here. If my supposition
is correct then the effect would be identical in any programming
language.
> # SEARCH THE LOG FILE FOR THE REQUESTED INFO
> $logfile = "\\\\machine_name\\path\\to\\logfile.log";
> # $logfile = "E:\\path\\to\\logfile.log";
>
> open (LOG, "$logfile") || die "Cannot open $logfile. $!";
In most situations, even on MS Windows, it is better to use forward
slashes:
my $logfile = "E:/path/to/logfile.log";
If you must use back slashes, do yourself a favor and single quote
them:
my $logfile = 'E:\path\to\logfile.log';
There's no reason to quote a variable by itself:
open (LOG, $logfile) || die "Cannot open $logfile. $!";
I can't find "Invalid argument" in perldiag, so I suspect you are
seeing a non-perl error.
Jon
--
Two are better than one, because they have a good return for their
work: If one falls down, his friend can help him up... Though one
may be overpowered, two can defend themselves. A cord of three
strands is not quickly broken. -- Ecclesiastes 4:9,12 (NIV)