I have been tasked with writing a basic package to map drives to NT and Windows 2000 servers. Based upon the domain that the server is located in, I simply use one of two different connection strings. To facilitate this, I simply perform 'nslookup' and call the appropriate syntax for Win32::NetResource::AddConnection. The problem that I am experiencing, is when I try to format a hash within a scalar to call AddConnection properly.
use Win32::NetResource qw(:DEFAULT AddConnection GetError); my $connex_string = null; my $win2k_uid = "uid"; my $win2k_pwd = "pwd"; my $persist = "/persistent:no"; if ($domain =~m/^domainOne$/i) { print "domainOne\n"; $net_resource = { "RemoteName" => "\\\\$object_md{MAP_SERVER}\\$argOne", "LocalName" => "$drive_letter", }; $connex_string = $net_resource; } elsif($domain =~m/^domainTwo$/i) { print "domainTwo\n"; $net_resource = { "RemoteName" => "\\\\$object_md{MAP_SERVER}\\$argOne", "LocalName" => $drive_letter, "Type" => "RESOURCETYPE_ANY", "Provider" => "", }; $connect_string = "$net_resource,$win2k_uid,$win2k_pwd,$persis +t"; } else { print "Undefined domain\n"; } if(AddConnection($connex_string)) { print "Connection work.\n"; } else { print "Connection did not work.\n"; }
This snippet of code gives me problems: $connect_string = "$net_resource,$win2k_uid,$win2k_pwd,$persist";
I know that it is the way that I am referencing the hash in the scalar.
This is the error that I am experiencing: "AddConnection: HASH reference required at C:/Perl/site/lib/Win32/NetResource.pm line 267."
I know how to reference the values of a hash with while and for loops. However, I just seem to have problems with hash references (i.e., \%hash, $$hash, %$hash, etc.). Can anyone offer some help? Also, in an effort to become a more competent programmer, is this the best way to accomplish the drive mappings to NT and Win 2K server?
Thanks in advance for any and all help!
TCF
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |