in reply to Accessing SMB Shares from Linux

You do not have to explicitly mount the share and unmount the share. You can get through via smbclient. There is an interesting module on CPAN called Filesys::SmbClient. I have copied and modified its sample script slightly -
use POSIX; use Filesys::SmbClient; my $smb = new Filesys::SmbClient(username => "alian", password => "speed", workgroup => "alian", debug => 10); # Read a file my $server="jupiter"; my $path="doc/general.css"; my $fd = $smb->open("smb://$server/$path", '0666'); while (defined(my $l= $smb->read($fd,50))) { print $l; } $smb->close(fd);
And of course you can access the file with a tied file handle for convenience as well.

Replies are listed 'Best First'.
Re: Re: Accessing SMB Shares from Linux
by TheFluffyOne (Beadle) on Nov 26, 2003 at 09:28 UTC

    Thanks Roger, and also to idsfa, for the replies.

    I'll take a look at both methods to see which works best for me.

    Is there a way to do this that is portable between Win32 and Linux, or am I going to need to write a wrapper to choose between Win32/Linux code?

        Is there a way to do this that is portable between Win32 and Linux

      Yes of course. You can check the $^O variable to see whether you are on Windows or Linux platform, and act accordingly.
      use strict; if ($^O ne 'MSWin32') { # NOT on windows? require POSIX; require Filesys::SmbClient; } ... sub OpenFile { my ($server, $path, $username .... ) = @_; if ($^O eq 'MSWin32') { # open file directly as //server/path on Windows ... } else { # open file via smbclient on *nix ... } }