2

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

1
  • == "" is wrong, == compares numbers, use eq to compare strings in Perl. Commented Jan 16, 2019 at 16:26

1 Answer 1

3

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.