I have a file lowercase.perl ,this takes one file as an input and prints all its content in lowercase into another output file.
use warnings;
use strict;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
while(<STDIN>) {
print lc($_);
}
and I want to run it from java
import java.io.*;
public class Sample {
public static void main(String args[]) {
Process process;
try
{
process = Runtime.getRuntime().exec("perl lowercase.perl <lower.eng> lowerlm.eng");
process.waitFor();
if(process.exitValue() == 0)
{
System.out.println("Command Successful");
}
else
{
System.out.println("Command Failure");
}
}
catch(Exception e)
{
System.out.println("Exception: "+ e.toString());
}
}
}
but this is not working.
All my files are in same directory and i am running terminal in same directory as well. What seems to be happening is that the perl script is being executed but the input parameter <lower.eng>
(this has to be passed with diamond operators) that i have passed is not working properly.
I have ran perl script directly and it is working fine if ran without using java.