Code Comments
Programming Forum and web based access to our favorite programming groups.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 t
he intended recipient. It may also contain confidential and privileged infor
mation. If you are not the intended recipient, any reliance on, use, disclo
sure, distribution or copyi
ng of this email or attachments is strictly prohibited. Please notify the se
nder immediately by email if you have received this message by mistake and d
elete the email and all attachments.
Any views or opinions in this email are solely those of the author and do no
t necessarily represent those of Trinity Mirror PLC or its associated group
companies (hereinafter referred to as "TM Group"). TM Group accept no liabil
ity for the content of this
email, or for the consequences of any actions taken on the basis of the info
rmation provided, unless that information is subsequently confirmed in writi
ng. Although every reasonable effort is made to keep its network free from v
iruses, 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 t
his address may be subject to interception or monitoring for operational rea
sons or for lawful busines
s practices.
Trinity Mirror PLC is the parent company of the Trinity Mirror group of com
panies and is registered in England No 82548, with its address at One Canada
Square, Canary Wharf, London E14 5AP.
********************
Post Follow-up to this messageneill.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.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.