Not sure if anyone has mentioned this already, lost some of the mail.

To run a perl script from PAR you can do the following:

do 'scriptfile.pl';

However, this will do the script in the current namespace (so any functions/globals the script defines will be included in your current namespace). You might be able to do this to force the scope to be limited to a block:

{ do 'scriptfile.pl' };

however, this is still unsafe.

Steve

Alan Stewart wrote:

On 22 Aug 2004 at 2:28, Pavel wrote:


Hello Alan,

Sunday, August 22, 2004, 1:24:52 AM, you wrote:

AS> On 22 Aug 2004 at 0:20, Pavel wrote:


Hello

I am trying to start perl script from PAR
script1.pl that runs without parameters and was converted to exe

script2.pl runs with parameters and should have the same environment
as script1.pl

I cannot chande or modify script2.pl so I need use it "as is"

"system", "exec", and using of `` dont help me because they start new
process in another enviroment etc.

AS> Not sure this is true. Doing:

AS>     system 'script2.pl', @ARGV;

AS> works for me.

ok, it works in common environment ,but not with par. Try:
pp -l script.pl -o test.exe -e "system 'script.pl';"

if you try to run test.exe on computer without perl installed it
will not run, but dialog "open with..." appears instead.


True. I didn't know all of your pre-conditions.



my approach was use "eval". this works with par:

...
eval{
# foreign code here
print "blabla";
}

but if I have
$code = 'print "blabla"';
I cannot evaluate this with "eval".



Why can't you "eval $code" ?


I have got answer from Alexandr, he suggested 'require':

@ARGV = ("-parameter1=foo","-parameter2=bar");
require "script2.pl";

so it working up to this code in script2.pl:

$retour=`$command 2>&1`;


This may depend on what the $command is.


that spawn command interpreter. So it dont working again :-((

anyway thanks!



This works:

inside.pl:

    #!perl -w
    use strict;

    my $results = `cmd /C dir @ARGV`;
    print $results;

outside.pl:

    #!perl -w
    use strict;

    local $/;
    open FH, "<$ENV{PAR_TEMP}/inside.pl";
    my $code = <FH>;
    close FH;

    @ARGV = ( "/W", "c:\\windows", "c:\\windows\\system" );
    eval $code;

pp command:

    pp -o test.exe -l inside.pl outside.pl

and the output of test.exe is a dir list of c:\windows and c:\windows\system, so the command interpreter is not the problem itself.

Is this anything like what you are trying to do? Are you trying to use "pp -g" on script1.pl?

Alan Stewart




Reply via email to