calling a perl script with arguments from a parent perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calling a perl script with arguments from a parent perl script
# 1  
Old 02-03-2012
calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard.


From parent.pl
$input1=123;
$input2=abc;

I tried calling it with
Code:
system("/usr/bin/perl child.pl $input1 $input2");

and 

`perl child.pl $input1 $input2`;

and

`perl child.p`l $input1 $input2;

None seem to work. Any suggestions?
# 2  
Old 02-03-2012
Works for me.

Code:
$ cat test.pl
#! /usr/bin/perl -w
use strict;
my ($i1, $i2) = (1, 2);
system ("/usr/bin/perl child.pl $i1 $i2");
$
$ cat child.pl
#! /usr/bin/perl -w
use strict;
print "@ARGV\n";
$
$ ./test.pl
1 2
$
$

Please post your parent and child programs. Will be easier to debug.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing arguments to a perl script

Hi I need to pass comma seperated arguments to a perl script? It is like: Exect.pl -d GUI1,GUI2,GUI3 and I need to store these argsGUI1,GUI2,GUI3 in an array. can anyone suggest how to do that: (1 Reply)
Discussion started by: rkrish
1 Replies

2. Shell Programming and Scripting

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 Replies

3. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

4. Shell Programming and Scripting

How to accept arguments in shell script when calling in perl

I have a shell script like this: #!/bin/sh $PYTHON MetarDecoder.py < ../data/mtrs/arg1/arg2 And I'm calling it with this in perl: my $output = `./metar_parse.sh --options`; It's successful when I put in actual values for arg1 and arg2 in the shell script, but I'd like to pass arguments... (1 Reply)
Discussion started by: civilsurfer
1 Replies

5. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

6. Shell Programming and Scripting

Calling 3 perl script from one

hi all, I have 3 perl scripts a.pl,b.pl and c.pl each of these work when i pass a date for eg: perl c.pl 2010-05-27 now i want to write a perl script that would call the 3 scripts and make it run all the 3 scripts (a.pl,b.pl,c.pl) parallelly rather than 1 after the other....... pls... (2 Replies)
Discussion started by: siva_nagarajan
2 Replies

7. Shell Programming and Scripting

Calling a shell script from a perl script

Hi, I have one shel script which returns some value and I am calling this shell script from a perl script which needs the out put/return value of shell script. But I don't know how to collect the output/return value of the shell script. Can any one give some idea on it? For example: The... (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

8. Shell Programming and Scripting

calling problem in perl script

Hi , Here is my piece of code-- main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

9. Shell Programming and Scripting

Calling a perl script from a perl script

printf(”Going to call another script... \n”); system(”/my_dir/B.pl”); # call another perl script B.pl exit; Hi everyone, above is an example that i am using to call another perl script from the current perl script. I have two concerns : 1) This there a better way of achieving the same... (6 Replies)
Discussion started by: new2ss
6 Replies

10. Shell Programming and Scripting

Passing arguments to a Perl script

I am playing around with Perl and wrote the script below that is executed from the command line, it will split data up in a file based on a value supplied. When executed you provide two arguments - the file that contains the data to be split and the character you want to split by. It works as... (4 Replies)
Discussion started by: jyoung
4 Replies
Login or Register to Ask a Question