Re: How can i make a perl program lauch another perl program that takes options



alex.jamestin+usenet@xxxxxxxxx wrote:
Hi all,

Any help on this would be appreciated :)

Currently I have a perl program thats required to call another perl
program. The second one takes arguments and can be called as:

perl vplan_all.pl 5.6 24.0 ajtest

Here 5.6, 24.0 and ajtest are all command line options.

I have to call this from a second program that i wrote. I tried the
call as below -

system( "perl vplan_all.pl 5.6 24.0")
or die "Couldn't run the vplan_all.pl script: $!\n";

However, this doesn't seem to work. The shell reports that perl can't
find the file. However, when i simply try with -

system( "perl vplan_all.pl")
or die "Couldn't run the vplan_all.pl script: $!\n";

The script is now called and i get the result -

vp_all: USAGE: perl vplan_all.pl <Version> <Build>
<File_name_to_be_created>

which is the expected behaviour when no options are provided.
So apparently the shell calls perl and passes the entire "perl
vplan_all.pl 5.6 24.0" as a chunk. Perl can't then seem to
differentiate between the code name and the options.

I've tried bypassing the shell [ system(xxx,xxx,xx)] but that doesn't
seem to help.

If vplan_all.pl is in fact it's own application, try calling it without
calling Perl first:

system("/path/to/program/vp_all.pl arg1 arg2") or die "blah blah: $!";

BTW, AFAIR, inserting a \n after the $! will negate the $!, but I may be
mistaken.

Steve
.



Relevant Pages

  • Re: Unexpected result from grep
    ... I'd worry about whether I should be using the shell at all. ... as big a deal as Perl. ... Most people can puzzle out even a complicated shell script and also ... seem to prefer ksh and it sure seems like a better shell to me. ...
    (comp.unix.tru64)
  • Re: Unexpected result from grep
    ... I'd worry about whether I should be using the shell at all. ... as big a deal as Perl. ... Most people can puzzle out even a complicated shell script and also ... seem to prefer ksh and it sure seems like a better shell to me. ...
    (comp.unix.shell)
  • Re: ActiveState: Cant spawn "cmd.exe"?
    ... >> When testing with ActiveState perl what shell are you running in? ... Normally, perl is built using MinGW in the cmd.exe shell, following the ... ActiveState perl, too) in a bash shell, though I've not personally done ...
    (comp.lang.perl.misc)
  • Re: how to easily determine shell script is running in background from within script
    ... That's not really the shell. ... That's the exit status of commands. ... process group of the terminal is the process' process group, ... There are a number of perl functions in the POSIX ...
    (comp.unix.shell)
  • shell power vs. modern GUI IDE
    ... I think that the power of shell programming (particularly with the use ... scripting + perl with programming with IDEs like Eclipse or NetBeans. ... Perhaps one problem in vim is the source code browsing: ...
    (de.comp.os.unix.programming)