Loading ...
Sorry, an error occurred while loading the content.
 

Re: Networking Perl to Windows NT 4.0

Expand Messages
  • daymobrew@yahoo.com
    I have ActiveState Perl 5.6. The Win32::NetResource module has functionality that may help you. The module description is: This module offers control over the
    Message 1 of 5 , Feb 5, 2001
      I have ActiveState Perl 5.6.
      The Win32::NetResource module has functionality that may help you.
      The module description is:
      This module offers control over the network resources of Win32. Disks,
      printers etc can be shared over a network.

      --- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
      > Hello to everybody,
      >
      > i am an absolutely Perl Beginner, so I guess that this might be the
      right way to solve my problem :-)
      >
      > I wrote a program that reads an ascii alarm-file and shows the
      content of this file in a html-table.
      > This works pretty good!
      >
      > But this program needs to run in an windows nt 4.0 network
      environment and i have to open windows
      > file shares to get access to other alarm files that i wish to read
      from.
      >
      > But how can I access these shares?
      >
      > mfg
      > Sascha Teifke
    • Sascha Teifke
      This looks very good, but how do i connect to an existing share? Is there a full documentation for this module?
      Message 2 of 5 , Feb 6, 2001
        This looks very good, but how do i connect to an existing share?
        Is there a full documentation for this module?

        On Mon, 05 Feb 2001 21:51:35 -0000, daymobrew@... wrote:

        >I have ActiveState Perl 5.6.
        >The Win32::NetResource module has functionality that may help you.
        >The module description is:
        >This module offers control over the network resources of Win32. Disks,
        >printers etc can be shared over a network.
        >
        >--- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
        >> Hello to everybody,
        >>
        >> i am an absolutely Perl Beginner, so I guess that this might be the
        >right way to solve my problem :-)
        >>
        >> I wrote a program that reads an ascii alarm-file and shows the
        >content of this file in a html-table.
        >> This works pretty good!
        >>
        >> But this program needs to run in an windows nt 4.0 network
        >environment and i have to open windows
        >> file shares to get access to other alarm files that i wish to read
        >from.
        >>
        >> But how can I access these shares?
        >>
        >> mfg
        >> Sascha Teifke
        >
        >
        >
        >
        >
      • daymobrew@yahoo.com
        ... In the ActivePerl 5.6 HTML docs anyway. Otherwise look at: http://search.cpan.org/doc/GSAR/libwin32-0.16/NetResource/NetResource. pm You ll have to figure
        Message 3 of 5 , Feb 6, 2001
          > Is there a full documentation for this module?
          In the ActivePerl 5.6 HTML docs anyway.

          Otherwise look at:
          http://search.cpan.org/doc/GSAR/libwin32-0.16/NetResource/NetResource.
          pm

          You'll have to figure out the details yourself. If you have access to
          some Microsoft Developer Studio docs on the networking APIs it may
          help figure out the meaning of the parameters in the Perl functions.

          I searched perl.com etc and found now AddConnection() examples.

          --- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
          > This looks very good, but how do i connect to an existing share?
          > Is there a full documentation for this module?
          >
          > On Mon, 05 Feb 2001 21:51:35 -0000, daymobrew@y... wrote:
          >
          > >I have ActiveState Perl 5.6.
          > >The Win32::NetResource module has functionality that may help you.
          > >The module description is:
          > >This module offers control over the network resources of Win32.
          Disks,
          > >printers etc can be shared over a network.
          > >
          > >--- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
          > >> Hello to everybody,
          > >>
          > >> i am an absolutely Perl Beginner, so I guess that this might be
          the
          > >right way to solve my problem :-)
          > >>
          > >> I wrote a program that reads an ascii alarm-file and shows the
          > >content of this file in a html-table.
          > >> This works pretty good!
          > >>
          > >> But this program needs to run in an windows nt 4.0 network
          > >environment and i have to open windows
          > >> file shares to get access to other alarm files that i wish to
          read
          > >from.
          > >>
          > >> But how can I access these shares?
          > >>
          > >> mfg
          > >> Sascha Teifke
          > >
          > >
          > >
          > >
          > >
        • daymobrew@yahoo.com
          I messed around a bit and got the following working. It maps drive T: to Machine Share, checks that a file is on the mapped share and then disconnects the
          Message 4 of 5 , Feb 6, 2001
            I messed around a bit and got the following working.
            It maps drive T: to \\Machine\Share, checks that a file is on the
            mapped share and then disconnects the share. Excuse any lack in error
            checking, this is a demo script.

            #!/usr/local/bin/perl

            use strict;
            use Win32::NetResource;

            my ( %NetResource, $ErrorCode );

            # Using '\\Machine\Share' (single quotes) gave me error 67.
            $NetResource{ 'RemoteName' } = "\\\\Machine\\Share";
            $NetResource{ 'LocalName' } = "T:";

            my ( $Password, $UserName ) = ( "", "" );


            if ( ! Win32::NetResource::AddConnection( \%NetResource ) )
            {
            print "Trying with password\n";
            if ( ! Win32::NetResource::AddConnection( \%NetResource,
            $Password, $UserName, 0 ) )
            {
            Win32::NetResource::GetError( $ErrorCode );
            print "Error code: $ErrorCode\n";
            warn "ERROR: Error creating connection.";
            die;
            }
            }

            print "SUCCESS: Connection created.";

            if ( -f "T:/file_on_share.txt" )
            {
            print "File exists on T:\n";
            if ( ! Win32::NetResource::CancelConnection( "T:", 0, 1 ) )
            {
            Win32::NetResource::GetError( $ErrorCode );
            print "Error code: $ErrorCode\n";
            print "ERROR: Connection not cancelled.\n";
            }
            else
            {
            print "SUCCESS: Connection cancelled.\n";
            }
            }
            else
            {
            print "ERROR: File does not exist on T:\n";
            }
            __END__

            Notes:
            1) The share I connected to allowed "Everyone" "Read" access so I
            don't know about the password protection version.
            2) As the share was not password protected, the "Trying with password"
            section was never called.
            3) Error 67 is "The network name cannot be found."
            4) When I ran this script with the "-w" switch, I got a bunch of
            "Uninitialized" warnings from the Win32::NetResource module. I didn't
            care to explore and resolve this.

            It now should be quite easy to adapt this code for your use.

            Damien.

            --- In perl-beginner@y..., daymobrew@y... wrote:
            > > Is there a full documentation for this module?
            > In the ActivePerl 5.6 HTML docs anyway.
            >
            > Otherwise look at:
            >
            http://search.cpan.org/doc/GSAR/libwin32-0.16/NetResource/NetResource.
            > pm
            >
            > You'll have to figure out the details yourself. If you have access
            to
            > some Microsoft Developer Studio docs on the networking APIs it may
            > help figure out the meaning of the parameters in the Perl functions.
            >
            > I searched perl.com etc and found now AddConnection() examples.
            >
            > --- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
            > > This looks very good, but how do i connect to an existing share?
            > > Is there a full documentation for this module?
            > >
            > > On Mon, 05 Feb 2001 21:51:35 -0000, daymobrew@y... wrote:
            > >
            > > >I have ActiveState Perl 5.6.
            > > >The Win32::NetResource module has functionality that may help
            you.
            > > >The module description is:
            > > >This module offers control over the network resources of Win32.
            > Disks,
            > > >printers etc can be shared over a network.
            > > >
            > > >--- In perl-beginner@y..., "Sascha Teifke" <sascha@t...> wrote:
            > > >> Hello to everybody,
            > > >>
            > > >> i am an absolutely Perl Beginner, so I guess that this might be
            > the
            > > >right way to solve my problem :-)
            > > >>
            > > >> I wrote a program that reads an ascii alarm-file and shows the
            > > >content of this file in a html-table.
            > > >> This works pretty good!
            > > >>
            > > >> But this program needs to run in an windows nt 4.0 network
            > > >environment and i have to open windows
            > > >> file shares to get access to other alarm files that i wish to
            > read
            > > >from.
            > > >>
            > > >> But how can I access these shares?
            > > >>
            > > >> mfg
            > > >> Sascha Teifke
            > > >
            > > >
            > > >
            > > >
            > > >
          Your message has been successfully submitted and would be delivered to recipients shortly.