Loading ...
Sorry, an error occurred while loading the content.

calling another perl script

Expand Messages
  • Electron One
    Hello All, I am working on this perl script that is going to be distributed to many different parts of the company, and I was wondering if anybody knew of a
    Message 1 of 3 , Feb 27 6:31 PM
    • 0 Attachment
      Hello All,

      I am working on this perl script that is going to be distributed to many
      different parts of the company, and I was wondering if anybody knew of a
      universal, general way to call perl scripts. Just to give you some idea, I
      have this perl script called XYZ.pl, that needs to be present whenever they
      run another perl script called file.pl. The problem is, the perl script
      file.pl is going to be used to on several different directories. I dont
      want to have to place a copy of file.pl and XYZ.pl on every single one of
      those directories. That would be too much.

      I've thought of having everybody map their network to some computer,
      located on the network, and using that mapped network, call each individual
      perl script. That would work fine except for two problems. For one, not
      everybody can map to the same network drive. For example, some people may
      have the "G:" available to map to that computer, where as other people may
      have "G:" already mapped to something else, and may need to use a different
      letter. etc...This problem is only an issue with XYZ.pl, because inside of
      file.pl I have to hard code where XYZ.pl is. So I cant say do 'G:xyl.pl';
      since not all people will have the G: drive free, some may need to use F:
      etc...

      Any suggestions?
    • Mike Southern
      If you are distributing file.pl on to each computer, then you already have perl installed on each computer, yes? To save mapping drives - and running errors
      Message 2 of 3 , Feb 29 7:40 PM
      • 0 Attachment
        If you are distributing file.pl on to each computer, then you already have
        perl installed on each computer, yes?

        To save mapping drives - and running errors when the drive map is lost
        (which *will* happen) - why not also place xyz.pl in a static folder on
        each machine, but call it from within file.pl using

        require ("c:/path/xyz.pl");

        It's sort-of hacky, but it will probably work.

        Another way: Force the remap the drive each time, and use a guaranteed
        unused drive letter.

        my $drive="u:";
        my $tcpip="xxx.xxx.xxx.xxx"; #ip address
        my $volume="c"; #shared volume
        my $login="login";
        my $password="password";

        #Unmap the drive first
        system "net use $drive /delete /yes";

        #Then remap it
        $mapok= (system "net use $drive \\\\$tcpip\\$volume /user:$login $password");

        #$mapok is a status check = if the map fails, value will be 0

        if ($mapok ne 0) {
        #do stuff here with mapped drive
        }


        Or, a final way, check the existence of the mapped drive before you access
        it. If you fail on a test for G:, try the next drive letter etc etc until
        you find a match.




        At 02/27/2004, you wrote:
        >Hello All,
        >
        > I am working on this perl script that is going to be distributed to many
        >different parts of the company, and I was wondering if anybody knew of a
        >universal, general way to call perl scripts. Just to give you some idea, I
        >have this perl script called XYZ.pl, that needs to be present whenever they
        >run another perl script called file.pl. The problem is, the perl script
        >file.pl is going to be used to on several different directories. I dont
        >want to have to place a copy of file.pl and XYZ.pl on every single one of
        >those directories. That would be too much.
        >
        > I've thought of having everybody map their network to some computer,
        >located on the network, and using that mapped network, call each individual
        >perl script. That would work fine except for two problems. For one, not
        >everybody can map to the same network drive. For example, some people may
        >have the "G:" available to map to that computer, where as other people may
        >have "G:" already mapped to something else, and may need to use a different
        >letter. etc...This problem is only an issue with XYZ.pl, because inside of
        >file.pl I have to hard code where XYZ.pl is. So I cant say do 'G:xyl.pl';
        >since not all people will have the G: drive free, some may need to use F:
        >etc...
        >
        >Any suggestions?
        >
        >
        >
        >
        >Unsubscribing info is here:
        >http://help.yahoo.com/help/us/groups/groups-32.html
        >Yahoo! Groups Links
        >
        >
        >
        >
      • Frederiko dos Santos Costa
        ... Here is another suggestion... It will obtain the next free driver letter available ... @drives= ( f , g , h , l ,... z ); for ($i=0;$i
        Message 3 of 3 , Mar 1, 2004
        • 0 Attachment
          Mike Southern wrote:

          >If you are distributing file.pl on to each computer, then you already have
          >perl installed on each computer, yes?
          >
          >To save mapping drives - and running errors when the drive map is lost
          >(which *will* happen) - why not also place xyz.pl in a static folder on
          >each machine, but call it from within file.pl using
          >
          >require ("c:/path/xyz.pl");
          >
          >It's sort-of hacky, but it will probably work.
          >
          >Another way: Force the remap the drive each time, and use a guaranteed
          >unused drive letter.
          >
          >my $drive="u:";
          >my $tcpip="xxx.xxx.xxx.xxx"; #ip address
          >my $volume="c"; #shared volume
          >my $login="login";
          >my $password="password";
          >
          >#Unmap the drive first
          >system "net use $drive /delete /yes";
          >
          >#Then remap it
          >$mapok= (system "net use $drive \\\\$tcpip\\$volume /user:$login $password");
          >
          >#$mapok is a status check = if the map fails, value will be 0
          >
          >if ($mapok ne 0) {
          >#do stuff here with mapped drive
          >}
          >
          >
          >Or, a final way, check the existence of the mapped drive before you access
          >it. If you fail on a test for G:, try the next drive letter etc etc until
          >you find a match.
          >
          >
          >
          >
          >At 02/27/2004, you wrote:
          > >Hello All,
          > >
          > > I am working on this perl script that is going to be distributed to many
          > >different parts of the company, and I was wondering if anybody knew of a
          > >universal, general way to call perl scripts. Just to give you some idea, I
          > >have this perl script called XYZ.pl, that needs to be present whenever they
          > >run another perl script called file.pl. The problem is, the perl script
          > >file.pl is going to be used to on several different directories. I dont
          > >want to have to place a copy of file.pl and XYZ.pl on every single one of
          > >those directories. That would be too much.
          > >
          > > I've thought of having everybody map their network to some computer,
          > >located on the network, and using that mapped network, call each individual
          > >perl script. That would work fine except for two problems. For one, not
          > >everybody can map to the same network drive. For example, some people may
          > >have the "G:" available to map to that computer, where as other people may
          > >have "G:" already mapped to something else, and may need to use a different
          > >letter. etc...This problem is only an issue with XYZ.pl, because inside of
          > >file.pl I have to hard code where XYZ.pl is. So I cant say do 'G:xyl.pl';
          > >since not all people will have the G: drive free, some may need to use F:
          > >etc...
          > >
          > >Any suggestions?
          > >
          > >
          > >
          > >
          > >Unsubscribing info is here:
          > >http://help.yahoo.com/help/us/groups/groups-32.html
          > >Yahoo! Groups Links
          > >
          > >
          > >
          > >
          >
          >
          >
          >Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
          >Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
          >
          >
          Here is another suggestion...
          It will obtain the next free driver letter available ...

          @drives= ("f","g","h","l",..."z");

          for ($i=0;$i<=$#drives;$i++) {
          #Try Mapping ...
          $mapok=system "net use $drives[$i] \\IP\Volume /user:login password"
          # Testing the return code
          if ($mapok ne 0) {
          $DriveConnected=$drives[$i];
          $i=$#drives + 1; # So, don't execute any loop anymore
          }
          }

          So, the variable $DriveConnected contains the assigned letter ... It may
          be a slower code, but I think it works too.

          I hope it also helps ...



          }
        Your message has been successfully submitted and would be delivered to recipients shortly.