Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: perl standalone to run perl script as a parameter

by chromatic (Archbishop)
on Jul 16, 2012 at 22:49 UTC ( #982096=note: print w/replies, xml ) Need Help??

in reply to perl standalone to run perl script as a parameter

Back up a step.

Do you need the ability to run one script from another, or do you have multiple scripts, each of which do different things, and you need to do those different things all from one process?

Put another way, why do you say you need to run a different script from the first one?

(The advice we give you will be different depending on what you're trying to accomplish, not how you have tried to accomplish it.)

Improve your skills with Modern Perl: the free book.

  • Comment on Re: perl standalone to run perl script as a parameter

Replies are listed 'Best First'.
Re^2: perl standalone to run perl script as a parameter
by eammendola (Initiate) on Jul 17, 2012 at 00:35 UTC
    Fair enough. I may be asking the question incorrectly. I'll back up a bit and explain why I am trying to do what I am trying to do. And I really appreciate your guy's patience.

    I am using a tool (IBM TEM) that can launch different types of processes on remote PCs. For example, I can tell it to run "perl" or "dir *.err" in a specific folder on a PC and use the processes to collect inventory data from that PC.

    I cannot (by policy) install Perl on these PCs. I can however, have a standalone perl.exe on them to use at my discretion.

    I am currently using a simple perl.exe (standalone) in a folder with some other tools. I did not make this exe, it was compiled by someone else (no longer here). I am calling this perl.exe remotely to run a configuration script written in Perl. The configuration script runs some system commands and parses the returned data. All that works.

    My example: "perl"

    My dilema:

    1. I need to change the abilities of the standalone perl.exe. I need a standalone perl.exe which has a few specific modules compiled with it AND probably have it be able to accept the configuration script as the parameter. For example, I want to add the Win32::TieRegistry module.

    2. I "could" compile the configuration script, along with the necessary modules and any command changes each time I need to update the In that case I would just run the invconfig as a standalone exe. I would like to avoid that and leave the perl.exe unchanged and only changing the, as needed. The configuration script gets updated regularly, adding and/or removing commands as needed. Because of this I don't want to have to recompile it each time. I also would like others to be able to do simple modifications to the without having to recompile it.

    So, ultimately I am trying to have a custom perl.exe that will only get rare updates (as needed), that will run a perl script and provide any required modules to it.

    I don't completely understand what has to be in the custom when I do Perl2Exe on it, so that it is able to run the configuration script.

    My examples in my original question show what I was attempting to do, but they do not work.

    If I compile it with this line, which I would guess should always run the same configuration script:  $ret = `perl`; when I try to run the custom perl.exe like this "customperl.exe", perl says it can't find perl (or similar error).

    If I try to compile it with one of these lines, presumably to locate the custom perl to execute the passed in script name:

    $ret = `$^X $ARGV[0]`; or system('$^X $ARGV[0]');
    I get a warning that perl is not found in the path during compile time.

    I'm trying to use a standalone perl to call itself and run a script. I can limit the placement to a single folder if necessary. Perhaps, I am approaching this whole thing incorrectly. I just don't know.

      Based on what you're describing, I personally would approach this in a totally different manner.

      It sounds like you're running something on a central system that issues remote commands to remote systems. That sounds like a network is involved. If so, the solution is very simple if you have the remote systems access a file share on the network.

      Here's what I would do in your situation:

      • Download a portable version of Strawberry Perl from here.
      • Put the unzipped portable Strawberry Perl in a shared network folder that can be accessed by the "client" systems.

      With portable Strawberry Perl, you're not installing Perl. Instead, you run a batch file that opens a command prompt and sets environment variables for just that command prompt. From that command prompt and only that command prompt, you can run Perl. With a little batch file tweaking, you can modify it to take inputs (such as the Perl script to run) and then it can run a Perl script with the full Perl environment.

      For example, I want to add the Win32::TieRegistry module.

      To have that or any other Perl module available, you just need to install those modules into the portable Strawberry Perl that's on that network share and then all of your "client" systems can use that module.

      To allow others to run their modified version of the Perl script without installing Perl on the remote systems, I believe this may be one of the easiest methods to do so.

        This is a great solution! In fact, I may use this sometime in the future for a different need. After reading this I set Strawberry Perl up on network share and tested it out. It certainly works (with my logon) and the modules can be installed in one place for everyone. Again, I really like this solution. Unfortunately, the tool calling the perl only has local admin privileges, so it cannot access shares setup to require logged on network accounts. After further discussion, I decided to use the old build and just do the extra coding instead of trying to compile my own with a few specific modules. I'd like to spend more time learning how to roll my own, but I am under time constraints to get this up and running. Thanks again.
      I cannot (by policy) install Perl on these PCs. I can however, have a standalone perl.exe on them to use at my discretion.
      Come one, give us a break! What is the difference between an "installed" Perl and a "standalone" Perl? Someone has been selling your IT security guys snake-oil.

      Download a portable Strawberry Perl on a clean PC, install all modules you need, zip it up again and put it on your target computers. Sell it as the new "standalone Perl" and enjoy full perliness on your machines.


      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982096]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-06-22 19:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.