call one perl script within another

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default call one perl script within another

    How Can I call a perl script within my main script

    If I do

    $response=`perl $somescript $args`;
    This will call a new perl process, and may be more expensive on the
    system. On the other hand I can do

    do "$somescript $args";

    But How do I get the reponse of the script.

    Is there a way or should I just use the backticks
    Thanks
    Ram





    Ramprasad A Padmanabhan Guest

  2. Similar Questions and Discussions

    1. PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
      Recently on perlmonks.com I have posted a prototype of Perl embeded into Java (#372197="Embeding Perl into Java to use CPAN modules directly from...
    2. How can I call MFC functions from Perl
      Hello, How can I call MFC functions from Perl? Which module / method I should select? Inline:C ? Inline:CPP ? XS ? or SWIG? Regards, Sankaran
    3. call win32 API from linux perl script
      Hi, I'm must calling an API from a remote win32 server in a perl script. On a windows server, I use win32::OLE and it's work fine ! But my...
    4. Control a non-perl image viewer from perl script
      Below is a (non-finished) script that trys to run a linux viewer called eog (eye of gnome) in a script that will eventually allow me to power thru...
    5. Execute shell script from a perl script
      Hi, How can I executed a Unix shell script from a Perl script. The shell script is a dump of a oracle table to a file. The perl script is for...
  3. #2

    Default Re: call one perl script within another

    > This will call a new perl process, and may be more expensive on the
    > system. On the other hand I can do
    <...>
    > But How do I get the reponse of the script.
    Probably the simpliest way is to make called script a module and run it
    using either 'use' or 'require'.

    Andrew Shitov Guest

  4. #3

    Default Re: call one perl script within another

    Andrew Shitov wrote:
    >> This will call a new perl process, and may be more expensive on the
    >> system. On the other hand I can do
    >
    > <...>
    >
    >> But How do I get the reponse of the script.
    >
    >
    > Probably the simpliest way is to make called script a module and run it
    > using either 'use' or 'require'.
    >
    Precisely , But That is something I cannot do because the script is in a
    file which is written on the fly by the client end settings.

    Ideally it should have been such a way that The client settings are
    written into a configuration file and the program reads the
    configuraton file and runs the condition.

    The point over here is , Is it possible to use the existing instance of
    perl running main to run the child program and return the output

    THanks
    Ram


    Ramprasad A Padmanabhan Guest

  5. #4

    Default Re: call one perl script within another

    my $return_value = eval {$code_or_sub_programme};

    Andrew Shitov Guest

  6. #5

    Default Re: call one perl script within another

    >>>>> "David" == David Van Der Geer <David.vanderGeer@axa.nl> writes:

    David> ************************************************** *******************
    David> This message is intended only for the person or entity to
    David> which it is addressed and may contain confidential and/or
    David> privileged information, the disclosure of which is prohibited.
    David> If you are not the intended recipient you may not read,
    David> use, disseminate or copy the information transmitted. If
    David> you have received this message in error, please contact
    David> the sender and delete the material from any computer.
    David> Dit bericht is uitsluitend bestemd voor de (rechts)persoon
    David> aan welke het is gericht. Het kan vertrouwelijke of
    David> alleen voor deze bestemde informatie bevatten, die niet
    David> mag worden geopenbaard. Als dit bericht niet voor u
    David> bestemd is, mag u de ontvangen informatie niet lezen,
    David> gebruiken, verspreiden of kopieren. Als u dit bericht
    David> abusievelijk hebt ontvangen, gelieve u het te deleten en
    David> contact op te nemen met de afzender.
    David> ************************************************** ******************



    David> ************************************************** ********************
    David> This email and any files transmitted with it are confidential and
    David> intended solely for the use of the individual or entity to whom they
    David> are addressed. If you have received this email in error please notify
    David> the system manager.

    David> This footnote also confirms that this email message has been swept by
    David> MIMEsweeper for the presence of computer viruses.

    David> [url]www.mimesweeper.com[/url]
    David> ************************************************** ********************

    Goodness, Gracious!

    31 lines of disclaimer, attached to a 15 line message (counting
    the quoted material).

    As I've said before:

    You have exceeded the 4-line .sig boilerplate limit with a
    worthless unenforcable disclaimer. Please remove this text from
    future postings to this mailing list. If you cannot do so for
    mail from your domain, please get a freemail account and rejoin
    the list from there.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

  7. #6

    Default Re: call one perl script within another


    > Andrew Shitov wrote:
    > >> This will call a new perl process, and may be more expensive on the
    > >> system. On the other hand I can do
    > >
    > > <...>
    > >
    > >> But How do I get the reponse of the script.
    > >
    > >
    > > Probably the simpliest way is to make called script a module and run it
    > > using either 'use' or 'require'.
    > >
    >
    > Precisely , But That is something I cannot do because the script is in a
    > file which is written on the fly by the client end settings.
    >
    > Ideally it should have been such a way that The client settings are
    > written into a configuration file and the program reads the
    > configuraton file and runs the condition.
    >
    > The point over here is , Is it possible to use the existing instance of
    > perl running main to run the child program and return the output
    >
    'require' is runtime not compile time, so assuming you can regulate the
    sequence of events, aka the file is known to be written (or testable in
    a loop) before the call to require then this will still work even if the
    file does not exist at runtime. If you are worried about the require
    failing because of a missing file then wrap the whole construct in an
    'eval' and catch the exceptions (which you should do anyways).

    .... still isn't a compelling reason to call one Perl script from another...

    [url]http://danconia.org[/url]

    Wiggins D Anconia Guest

  8. #7

    Default Re: call one perl script within another

    I think there's a function called eval which lets you evaluate perl code
    on the fly. [url]http://www.perldoc.com/perl5.8.0/pod/func/eval.html[/url]

    -Dan

    Dan Anderson Guest

  9. #8

    Default RE: call one perl script within another

    System will fork a second shell process from the parent and wait for a
    response when the child process exits (which sounds like what you want).
    This is not so efficient as exec which kills the parent process.

    For system:

    my $return = system (my_script, my_argument);

    Will start a child process and wait until it completes returning an exit
    value.

    Regards

    Rick

    Dr Richard Edwards, Web Developer
    Sift, 100 Victoria Street, Bristol, BS1 6HZ, UK
    Tel: +44 117 9159600 Fax: +44 117 9159630
    [url]http://www.sift.co.uk[/url]


    -----Original Message-----
    From: Geer, David van der [mailto:David.vanderGeer@axa.nl]
    Sent: 21 October 2003 08:03
    To: Ramprasad A Padmanabhan; [email]beginners@perl.org[/email]
    Subject: RE: call one perl script within another

    > How Can I call a perl script within my main script
    > If I do
    > $response=`perl $somescript $args`;
    This will fork and open a shell so is slow
    > do "$somescript $args";
    > But How do I get the reponse of the script.
    > Is there a way or should I just use the backticks
    Please look at system() and exec() this should help you out.

    Regs David
    > Thanks
    > Ram



    Rick Edwards Guest

  10. #9

    Default Re: call one perl script within another

    When i am running the below program i got the error as permission denied
    /usr/bin/perl -w
    print ”this is calling script \n ";
    system "/myhome/caller_script.pl”;
    exit;
    I need to write a script that should call another script
    pls help me.
    ramya Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139