Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Learning how to map a drive in Perl
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.
********************

Report this thread to moderator Post Follow-up to this message
Old Post
Neill Taylor
03-27-04 04:14 AM


Re: Learning how to map a drive in Perl
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Randy W. Sims
03-27-04 04:14 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.