Win has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

How do I get VBA code in an Excel file to system call a Perl program that is held on a network drive? The catch is, I want the Perl program to run on a machine that is different to the machine that is sending the request. This other machine is similarly connected to the network drive.

Also, we use temporary IP addresses. How do I get a Perl program to find the IP address of a particular machine? I want my Perl program to be held on a network drive, which is an additional problem.

Retitled by davido per consideration.

  • Comment on Getting VBA code to run a Perl script in a network drive

Replies are listed 'Best First'.
Re: Getting VBA code to run a Perl script in a network drive
by BrowserUk (Patriarch) on Dec 09, 2004 at 13:49 UTC

    This isn't a Perl problem. If you can work out how to call any executable in the way you want to call your Perl script, then you only have to substitute the appropriate command line. Something like:

    \\machineWithPerl\path\To\perl.exe \\MachineWithYourScript\path\to\You +rScript.pl

    But that leaves how to invoke an executable, via VBA, from within Excel, to run on a remote machine, having discovered the appropriate IP.

    All of which is nothing to do with Perl, and this is almost certainly not the best place to get that expertise.


    Examine what is said, not who speaks.        The end of an era!
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re: Getting VBA code to run a Perl script in a network drive
by gellyfish (Monsignor) on Dec 09, 2004 at 14:17 UTC

    You could possibly do this using A Windows Script Component written in Perl which encapsulates your Perl 'program' and call this using DCOM from your VBA code (the VBA with Office XP has an enhanced CreateObject that allows you to specify a remote server name) - you should be able to use the remote machines NetBIOS name to reference it independently from its IP

    /J\

Re: Getting VBA code to run a Perl script in a network drive
by Grygonos (Chaplain) on Dec 09, 2004 at 13:54 UTC

    the start command (if you can execute system commands from vba) with the perl file as the parameter should work on a windows box. if the machine is constantly connected to the network with the same name then you can identify it. However the request initiator will need to send a request to a request handler on the target machine.. the request handler would then execute the program on its local machine. IO::Socket would be your best bet to get started in terms of setting up a requester/handler mechanism. However you will need to translate the network name to an IP address. CPAN might have a module that will do that. i.e \\HANDLER eq '192.168.1.105' Having the perl program held on the network drive isn't an issue.. the handler just has to know what drive letter it is mapped to on the handler. the requestor doesn't care.

    /ramble off
      Would it be suitable to have a Perl program running in the background that looks for submitted requests to the network drive, acting accordingly when it finds them? Can anyone point me to the best approach to doing this (if it is feasible)?
        Sure, you could do something like this on the machine you want the job processes to actually run on:
        use File::Slurp; chdir '/path/to/shared/directory/jobs/dropoff' or die $!; for (;;) { foreach my $job (read_dir(".")) { next unless $job =~ /\.pl$/; system "perl -w $job > $job.output"; rename $job, "$job.ran" or warn $!; } sleep 5; }
        You probably want to do something fancier with giving jobs unique names and so on, but that's the idea.

        Make sure the dropoff area has appropriate permissions.

        As for the dynamic IP thing, get your sysadmin to set up DNS properly so you can refer to the machine by name.

        If that's not possible, an easy fix would be to do whatever the windows equivalent of HEAD http://machine-you-control/here-i-am-`hostname` is in a DHCP client script, and then look in the logs on machine-you-control.