sravs
sravs

Reputation: 61

how to pass an empty String from perl Script to java file as a command line argument

I have a Script order.pl it has 3 variables

$dbcount=$ARGV[0];
if($dbcount == ""){$dbcount = 196001;}

$Num_Batches =$ARGV[1];
if($Num_Batches == ""){$Num_Batches=1;}
print "batches:$Num_Batches\t";

$TimeStamp = $ARGV[2];
if($TimeStamp == ""){$TimeStamp = "";}

$DBFetch = 'java GetWOConfHold_Auto '. $dbcount." ".$TimeStamp ;
print "DBFetch:$DBFetch\n";
print "timestamp :$TimeStamp";
system($DBFetch);

Here the java file is GetWOConfHold_Auto.java and i want to sent both dbcount and empty String to the GetWoConfHol_Auto java file as a command line arguments but

while running it is showing

perl order.pl 196000 1
batches:1       timestamp:      dbcount:196000  DBFetch:java GetWOConfHold_Auto 196000 

timestamp :args[0] 19600 

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
        at GetWOConfHold_Auto.main(GetWOConfHold_Auto.java:18)
no of picking updates data : 0
No data.exiting

I tried to print the timestamp but it is showing

timestamp :args[0] 19600  not the empty String

and in java it is stopping at the main method signature

I want to sent the empty String to java file as a command line argument. and i check if timestamp is null just go and pick the value from the properties file

Upvotes: 2

Views: 190

Answers (1)

choroba
choroba

Reputation: 241848

In the string variant of system, you need to quote the empty string. Have you tried the list version of system?

my $DBFetch = system 'java', 'GetWOConfHold_Auto' ,$dbcount, $TimeStamp;

Upvotes: 3

Related Questions