For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2004 > Learning how to map a drive in Perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Learning how to map a drive in Perl
Neill Taylor

2004-03-26, 11:14 pm

I am looking at how I could connect to share and map a local drive in a
perl script. I have cut and pasted the code from the man page from Lanman
to understand what is happening.

When I run the code below I get the following error

Undefined subroutine &main::USE_IPC called at map.pl line 5.

Am I missing something ?

Cheers

Neill


#!/usr/bin/perl
use strict;
use warnings;
# use win32::Lanman;
if(!Win32::Lanman::NetUseAdd({remote => "\\\\server\\ipc\$",
password => "pass",
username => "user",
domain => "NT",
asg_type => &USE_IPC}))
{
print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
}

#connects drive h: to \\testserver\testshare.

if(!Win32::Lanman::NetUseAdd({remote => "\\\\testserver\\testshare",
local => "h:",
asg_type => &USE_DISKDEV}))
{
print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
}



Undefined subroutine &main::USE_IPC called at map.pl line 5.







********************
IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copyi
ng of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments.

Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as "TM Group"). TM Group accept no liability for the content of this
email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no
liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful busines
s practices.

Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP.
********************
Randy W. Sims

2004-03-26, 11:14 pm

neill.taylor@trinityst.co.uk wrote:
> I am looking at how I could connect to share and map a local drive in a
> perl script. I have cut and pasted the code from the man page from Lanman
> to understand what is happening.
>
> When I run the code below I get the following error
>
> Undefined subroutine &main::USE_IPC called at map.pl line 5.
>
> Am I missing something ?
>
> Cheers
>
> Neill
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> # use win32::Lanman;
> if(!Win32::Lanman::NetUseAdd({remote => "\\\\server\\ipc\$",
> password => "pass",
> username => "user",
> domain => "NT",
> asg_type => &USE_IPC}))

^^^^^^^^
The problem is perl interprets the above marked code as: assign the
value returned from a call to the subroutine USE_IPC() to the key
asg_type. I'm not familiar with the Lanman module, but I'm guessing that
is supposed to be a constant. You probably need to either fully qualify
the constant (eg Win32::Lanman::USE_IPC) or import the constant into the
current namespace (eg use Win32::Lanman (USE_IPC)).


> {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> exit 1;
> }
>
> #connects drive h: to \\testserver\testshare.
>
> if(!Win32::Lanman::NetUseAdd({remote => "\\\\testserver\\testshare",
> local => "h:",
> asg_type => &USE_DISKDEV}))
> {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> exit 1;
> }
>
>
>
> Undefined subroutine &main::USE_IPC called at map.pl line 5.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com