Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

netBEUI win32 CGI and other stuff

by daemonchild (Acolyte)
on May 26, 2000 at 05:25 UTC ( #14904=perlquestion: print w/ replies, xml ) 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');

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

any help would be appreciated

steve

Comment on netBEUI win32 CGI and other stuff
Download Code
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);
    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
Re: netBEUI win32 CGI and other stuff
by Anonymous Monk on May 26, 2000 at 11:45 UTC
    Opps this should be readable
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://14904]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-07-11 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (224 votes), past polls