Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open error message "Invalid argument"

289 views
Skip to first unread message

Michael Nass

unread,
Dec 18, 2001, 1:02:01 PM12/18/01
to
I've searched all over for some sort of documentation on this but
haven't been able to find any. I'm trying to open a file inside a
perl script but keep getting the error "Invalid Argument". Normally,
I use perl on linux but I'm forced at this time to run it on WinNT.
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. 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

nob...@mail.com

unread,
Dec 19, 2001, 12:48:53 PM12/19/01
to
then...@hotmail.com (Michael Nass) wrote in message news:<714517c9.01121...@posting.google.com>...

> I've searched all over for some sort of documentation on this but
> haven't been able to find any.

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.

Jon Ericson

unread,
Dec 21, 2001, 11:27:31 AM12/21/01
to
then...@hotmail.com (Michael Nass) writes:

> # 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)

0 new messages