[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/bin/ -> maptodo.pl (source)

   1  # used to map a drive with authentication upon restart and
   2  #  run todo.pl --go
   3  #
   4  #  By Shad Lords for the Unattended project
   5  
   6  use warnings;
   7  use strict;
   8  use Pod::Usage;
   9  use Win32::NetResource;
  10  
  11  my ($netres, $tmp, $error, $drivemapped, $uncpath);
  12  
  13  if ((@ARGV == 2) || (@ARGV == 4)) {
  14      my ($drive, $share, $user, $password) = @ARGV;
  15  
  16      $drive =~ /^[a-z]:?$/i
  17          or die "Invalid drive specification $drive";
  18  
  19      # Add colon if needed.
  20      $drive =~ /:$/
  21          or $drive .= ':';
  22  
  23      $netres = {
  24          "RemoteName" => "$share",
  25          "LocalName" => "$drive"
  26          };
  27  
  28      print("Mapping: $$netres{LocalName} => $$netres{RemoteName}\n");
  29      $drivemapped = 120;
  30      while ($drivemapped > 0) {
  31          $drivemapped--;
  32          Win32::NetResource::GetUNCName($uncpath, $drive);
  33          if (("$uncpath" eq "$share") && ( -r "$drive\\bin\\todo.pl" )) {
  34              print("Running: $drive\\bin\\todo.pl --go\n");
  35              $drivemapped = -1;
  36              system ("$drive\\bin\\todo.pl --go");
  37          } else {
  38              sleep(1);
  39              Win32::NetResource::CancelConnection("$drive",1,1);
  40              $user ? Win32::NetResource::AddConnection($netres,$password,$user,0)
  41                  : Win32::NetResource::AddConnection($netres);
  42          }
  43      }
  44  
  45      if (! $drivemapped) {
  46          print "\nError mapping drive ... Quitting\n";
  47          while (1) {
  48              sleep 3600;
  49          }
  50      }
  51  } else {
  52      pod2usage (2);
  53  }
  54  
  55  __END__
  56  
  57  =head1 NAME
  58  
  59  maptodo.pl - Map drive and run todo.pl
  60  
  61  =head1 SYNOPSIS
  62  
  63  maptodo.pl <drive> <share> [ <user> <password> ]


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1