开发者

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 ,$DB开发者_如何学JAVAI::err, $DBI::errstr );

report_generation($db_conn);


See system() or ``


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜