stewartski has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perlmonks,

I suspect this is a trivial question, although I've not been able to find an answer so far.

Using Perl, I need to access some files that are on a different server to that of the script, although both are on our network. The files are in a password protected folder. (Don't worry, this is all legal, and eventually the bureaucracy here will tell me what that password is.)

My question is: using 'chdir' or 'opendir' how can I pass the password parameter. The only thing I can think of might be to use 'here doc' type syntax ie. <<. I have used this method in the past to pass a username and password for an ftp script.

Does anyone know if this is possible, or if there is a better method?

Many thanks
stewartski

  • Comment on accessing files in a password protected folder

Replies are listed 'Best First'.
Re: accessing files in a password protected folder
by gellyfish (Monsignor) on Mar 02, 2005 at 11:20 UTC

    I think you are going to have to be more specific how you are intending to access these files on a different server - are you using NFS, SMB, FTP, WebDAV or what?

    /J\

Re: accessing files in a password protected folder
by dorward (Curate) on Mar 02, 2005 at 11:21 UTC

    Are you asking about accessing SMB (Windows File and Print Sharing) shares? If so, then I would imagine that you should be looking at SMB::Client.

    It might be easier to mount the remote directory before running your Perl script (in Windows-land this process is handled by Mapping)

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: accessing files in a password protected folder
by jbrugger (Parson) on Mar 02, 2005 at 11:35 UTC
    assuming the script is on a *nix server, mount the remote filsystem using nfs or smb as suggested above, using the -o paramaters to set the 'owner' or proper rights to the mounted folder
    Second run the script as the user that has the rights on the mounted dir.
Re: accessing files in a password protected folder
by rupesh (Hermit) on Mar 02, 2005 at 11:38 UTC
    If you're running on Windows, then you have the RUNAS command at your service.

    Cheers,
    Rupesh.