2011-02-15 6 views
0

code Perl est ressemble -Comment appeler un script Shell avec des arguments variables d'un script Perl?

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); 

Répondre

2

Utilisez un tableau pour contenir les arguments, puis:

system @array; 

Il y a un certain nombre d'avantages à ce mécanisme - notamment que vous n'avez pas à tout échapper pour empêcher le shell d'interpréter les arguments avant de l'appeler.

Questions connexes