No such thing as a small change PerlMonks

### netBEUI win32 CGI and other stuff

by daemonchild (Acolyte)
 on May 26, 2000 at 05:25 UTC Need Help??
daemonchild has asked for the wisdom of the Perl Monks concerning the following question:

<html> <body> Recently I wrote a generic log checking script that runs as a CGI on my linux box. I was showing my boss at work and he asked me if I could modify it to run on his machine, running NT 4, as at my workplace there are several flaky servers running servlets, ftp, http and other services, and having a centralised form for checking the logs of them all would be a huge time-saver.

So I made some minor changes, but figured I didn't have to do too many alterations, as I wasn't doing anything "weird" in the script. Yet it refuses to work on NT.

I wrote some simple test scripts, and I believe I have tracked down one of the problems. Is there a special module I need to use to access files through the netBEUI protocol? I did a couple of searches for one, but came up with nothing that really answered my question.

As it stands now, my script fails on this line:

open(FILE,'\\server\path\to\file');
[download]

any ideas? or any favorite resources for CGI programming in win32?

any help would be appreciated

steve

Replies are listed 'Best First'.
Re: netBEUI win32 CGI and other stuff
by Anonymous Monk on May 26, 2000 at 11:45 UTC
this is a bit cleaner.
open(FH, "//server/path/to/file") or die $!; print while(<FH>); close (FH); for a bit of an explanation: Perl sees the \ as a meta escape in " strings. so "\\server\path\to\file" becomes "serverpathtofile" there are the solutions: double slashes: "\\\\server\\path\\to\\file" unix path symantics: "//server/path/to/file" this works because perl understands both even on NT ' quoted string '\\server\path\to\file' this works because single quoted strings ignore meta chars. Hope this helped. -wyn or using a single quoted here, which is the only type of quoting mechanism in perl where a backslash need not be escaped. (Thanks Tye) my$loc=<<'EOSTR';
\\server\path\to\file
EOSTR
[download]
:-)
Re: netBEUI win32 CGI and other stuff
by httptech (Chaplain) on May 26, 2000 at 08:21 UTC
The closest thing I see is Win32::NetResource, which has provisions for connecting to shares, but I don't see any implementation for actually using those shares.

Stabbing in the dark here; If I had to do this, the first thing I would look to see is if there are Win32 API calls to connect a remote share to a local drive letter, use the Win32::API module to do this, then access the file as if it were on a local drive.

RE: netBEUI win32 CGI and other stuff
by t0mas (Priest) on May 26, 2000 at 10:20 UTC
Don't know if this is your problem, but to make it work I put double backslashes in the path.
open(FILE),'<\\\\server\\path\\to\\file') or die $!; while (<FILE>) { print; } close(FILE); [download] And it works well for me. /brother t0mas Re: netBEUI win32 CGI and other stuff by Anonymous Monk on May 26, 2000 at 11:42 UTC this is a bit cleaner. open(FH, "//server/path/to/file") or die$!; print while(<FH>); close (FH); for a bit of an explanation: Perl sees the \ as a meta escape in " strings. so "\\server\path\to\file" becomes "serverpathtofile" there are the solutions: double slashes: "\\\\server\\path\\to\\file" unix path symantics: "//server/path/to/file" this works because perl understands both even on NT ' quoted string '\\server\path\to\file' this works because single quoted strings ignore meta chars. Hope this helped. -wyn

Create A New User
Node Status?
node history
Node Type: perlquestion [id://14904]
Approved by root
help
Chatterbox?
 [choroba]: Hey [Discipulus]: all is well.. flying home

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-02-21 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When it is dark outside I am happiest to see ...

Results (285 votes). Check out past polls.

Notices?