user617260
user617260

Reputation: 1

How to call a Shell script with variable arguments from a perl script?

Perl code is looks like --

sub report_generation($)
{

Shell_sh $ARGV[0] $conn_string $pm_dir/$FILE

}

$ARGV[0] -- > command line argument of perl script

$conn_string --> used in perl script value define in perl script 

my $USR=$ARGV[1];
my $PSS=$ARGV[2];
my $INS=$ARGV[3];
my $conn_string=$USR."/".$PSS."\@".$INS; 


$pm_dir/$FILE --> want to give file name with file path "$pm_dir/$FILE"


my $pm_dir="$ENV{'ABP_PM_ROOT'}/interfaces/output/report/$date";
my $FILE= 'FILE_NAME_'.$ARGV[0].'_'.get_timestamp().'.dat';


my $db_conn =DBI->connect( 'dbi:Oracle:'. $INS, $USR, $PSS, {AutoCommit => 0 })|| ExitProcess4 (1,$Function_Name ,$DBI::err, $DBI::errstr );

report_generation($db_conn);

Upvotes: 0

Views: 1866

Answers (2)

Jonathan Leffler
Jonathan Leffler

Reputation: 753475

Use an array to hold the arguments, and then:

system @array;

There are a number of advantages to that mechanism - notably that you do not have to escape everything to prevent the shell interpreting the arguments before you call it.

Upvotes: 2

user180100
user180100

Reputation:

See system() or ``

Upvotes: 2

Related Questions